Skip to content

Commit

Permalink
add lib directory to indent script
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmyhill committed May 18, 2021
1 parent f7b25f7 commit 8d813e6
Show file tree
Hide file tree
Showing 19 changed files with 504 additions and 519 deletions.
10 changes: 5 additions & 5 deletions indent
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Indentation and formatting script for VESIcal

if test ! -d VESIcal -o ! -d tests ; then
if test ! -d VESIcal -o ! -d lib -o ! -d tests ; then
echo "*** This script must be run from the top-level directory of VESIcal."
exit 1
fi
Expand All @@ -12,7 +12,7 @@ echo "--- Indenting all VESIcal header and source files"


# remove execute permission on source files:
find VESIcal tests \( -name '*.py' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 50 -P 10 chmod -x
find VESIcal lib tests \( -name '*.py' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 50 -P 10 chmod -x

# convert dos formatted files to unix file format by stripping out
# carriage returns (15=0x0D):
Expand All @@ -24,7 +24,7 @@ dos_to_unix()
rm -f $f.tmp
}
export -f dos_to_unix
find VESIcal tests \( -name '*.py' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 1 -P 10 -I {} bash -c 'dos_to_unix "$@"' _ {}
find VESIcal lib tests \( -name '*.py' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 1 -P 10 -I {} bash -c 'dos_to_unix "$@"' _ {}


# Remove trailing whitespace from files
Expand All @@ -38,7 +38,7 @@ remove_trailing_whitespace()
rm -f $f.tmp
}
export -f remove_trailing_whitespace
find VESIcal tests \( -name '*.bash' -o -name '*.py' -o -name '*.txt' -o -name '*.tex' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 1 -P 10 -I {} bash -c 'remove_trailing_whitespace "$@"' _ {}
find VESIcal lib tests \( -name '*.bash' -o -name '*.py' -o -name '*.txt' -o -name '*.tex' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 1 -P 10 -I {} bash -c 'remove_trailing_whitespace "$@"' _ {}

# Ensure only a single newline at end of files
ensure_single_trailing_newline()
Expand All @@ -64,6 +64,6 @@ ensure_single_trailing_newline()
rm -f $f.tmp $f.tmpi
}
export -f ensure_single_trailing_newline
find VESIcal tests \( -name '*.bash' -o -name '*.py' -o -name '*.txt' -o -name '*.tex' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 1 -P 10 -I {} bash -c 'ensure_single_trailing_newline "$@"' _ {}
find VESIcal lib tests \( -name '*.bash' -o -name '*.py' -o -name '*.txt' -o -name '*.tex' \) -not -path "VESIcal/tasplot/*" -print | xargs -n 1 -P 10 -I {} bash -c 'ensure_single_trailing_newline "$@"' _ {}

exit 0
2 changes: 1 addition & 1 deletion lib/VESIcal.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ VESIcal/models/magmasat.py
VESIcal/models/moore.py
VESIcal/models/shishkina.py
VESIcal/tasplot/__init__.py
VESIcal/tasplot/setup.py
VESIcal/tasplot/setup.py
1 change: 0 additions & 1 deletion lib/VESIcal.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

2 changes: 1 addition & 1 deletion lib/VESIcal/batchfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class BatchFile(object):
OPTIONAL. For Excel files. Default value is 0 which gets the first sheet in the batch spreadsheet file. This implements the pandas.
read_excel() sheet_name parameter. But functionality to read in more than one sheet at a time (e.g., pandas.read_excel(sheet_name=None))
is not yet imlpemented in VESIcal. From the pandas 1.0.4 documentation:
Available cases:
- Defaults to 0: 1st sheet as a DataFrame
- 1: 2nd sheet as a DataFrame
Expand Down
62 changes: 31 additions & 31 deletions lib/VESIcal/batchmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ def calculate_dissolved_volatiles(self, temperature, pressure, X_fluid=1, print_
X_fluid = row[X_name]

# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
bulk_comp.set_default_normalization(self.default_normalization)
Expand Down Expand Up @@ -262,9 +262,9 @@ def calculate_dissolved_volatiles(self, temperature, pressure, X_fluid=1, print_
if temperature > 0 and pressure > 0 and X_fluid >=0 and X_fluid <=1:
try:
# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
bulk_comp.set_default_normalization(self.default_normalization)
Expand Down Expand Up @@ -301,7 +301,7 @@ def calculate_dissolved_volatiles(self, temperature, pressure, X_fluid=1, print_
dissolved_data["Errors"] = errors

return dissolved_data

else:
XH2Ovals = []
XCO2vals = []
Expand All @@ -314,9 +314,9 @@ def calculate_dissolved_volatiles(self, temperature, pressure, X_fluid=1, print_
if file_has_X == True:
X_fluid = row[X_name]
# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
bulk_comp.set_default_normalization(self.default_normalization)
Expand Down Expand Up @@ -417,9 +417,9 @@ def calculate_equilibrium_fluid_comp(self, temperature, pressure=None, print_sta
if file_has_press == True:
pressure = row[press_name]
# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
bulk_comp.set_default_normalization(self.default_normalization)
Expand Down Expand Up @@ -474,9 +474,9 @@ def calculate_equilibrium_fluid_comp(self, temperature, pressure=None, print_sta
if temperature > 0 and pressure > 0:
try:
# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
bulk_comp.set_default_normalization(self.default_normalization)
Expand Down Expand Up @@ -514,9 +514,9 @@ def calculate_equilibrium_fluid_comp(self, temperature, pressure=None, print_sta
if file_has_press == True:
pressure = row[press_name]
# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
bulk_comp.set_default_normalization(self.default_normalization)
Expand Down Expand Up @@ -550,8 +550,8 @@ def calculate_saturation_pressure(self, temperature, print_status=None, model='M
title in the passed BatchFile object.
print_status: bool
OPTIONAL: The default value for MagmaSat is True and the default for all other models is False. If set to True, the
progress of the calculation will be printed to the terminal. If set to False, nothing will be printed. MagmaSat
OPTIONAL: The default value for MagmaSat is True and the default for all other models is False. If set to True, the
progress of the calculation will be printed to the terminal. If set to False, nothing will be printed. MagmaSat
calculations tend to be slow, and so a value of True is recommended more most use cases.
model: string
Expand Down Expand Up @@ -598,8 +598,8 @@ def calculate_saturation_pressure(self, temperature, print_status=None, model='M
if file_has_temp == True:
temperature = row[temp_name]
# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
Expand Down Expand Up @@ -650,17 +650,17 @@ def calculate_saturation_pressure(self, temperature, print_status=None, model='M
if temperature > 0:
try:
# Get sample comp as Sample class with defaults
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
bulk_comp = self.get_sample_composition(index,
normalization=self.default_normalization,
units='wtpt_oxides',
asSampleClass=True)
bulk_comp.set_default_units(self.default_units)
bulk_comp.set_default_normalization(self.default_normalization)

calc = calculate_classes.calculate_saturation_pressure(sample=bulk_comp,
temperature=temperature,
model=model,
verbose=True,
calc = calculate_classes.calculate_saturation_pressure(sample=bulk_comp,
temperature=temperature,
model=model,
verbose=True,
silence_warnings=True)
satP.append(calc.result["SaturationP_bars"])
flmass.append(calc.result["FluidMass_grams"])
Expand Down Expand Up @@ -700,4 +700,4 @@ def BatchFile_from_DataFrame(dataframe, units='wtpt_oxides', label=None):
-------
VESIcal.BatchFile object
"""
return BatchFile(filename=None, dataframe=dataframe, units=units, label=label)
return BatchFile(filename=None, dataframe=dataframe, units=units, label=label)
10 changes: 5 additions & 5 deletions lib/VESIcal/calculate_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ def return_default_units(self, sample, calc_result, **kwargs):
# check if calculation result is H2O-only, CO2-only, or mixed H2O-CO2
if isinstance(self.model_name, str):
if self.model_name in models.get_model_names(model='mixed'):
# set dissolved H2O and CO2 values.
# set dissolved H2O and CO2 values.
# this action assumes they are input as wt% but updates the composition in its default units.
bulk_comp.change_composition({'H2O': calc_result['H2O_liq'],
bulk_comp.change_composition({'H2O': calc_result['H2O_liq'],
'CO2': calc_result['CO2_liq']})
return {'H2O_liq': bulk_comp.get_composition(species='H2O', units=default_units),
'CO2_liq': bulk_comp.get_composition(species='CO2', units=default_units)}
Expand All @@ -119,7 +119,7 @@ def return_default_units(self, sample, calc_result, **kwargs):
bulk_comp.change_composition({'CO2': calc_result})
return bulk_comp.get_composition(species='CO2', units=default_units)
elif self.model_name == 'MagmaSat':
bulk_comp.change_composition({'H2O': calc_result['H2O_liq'],
bulk_comp.change_composition({'H2O': calc_result['H2O_liq'],
'CO2': calc_result['CO2_liq']})
if 'verbose' in kwargs and kwargs['verbose'] == True: # check if verbose method has been chosen
return {'H2O_liq': bulk_comp.get_composition(species='H2O', units=default_units),
Expand All @@ -130,8 +130,8 @@ def return_default_units(self, sample, calc_result, **kwargs):
else:
return {'H2O_liq': bulk_comp.get_composition(species='H2O', units=default_units),
'CO2_liq': bulk_comp.get_composition(species='CO2', units=default_units)}
else:
# if self.model_name is not a string, most likely this is a user-created model class,
else:
# if self.model_name is not a string, most likely this is a user-created model class,
# and so we cannot interrogate it for model type (H2O, CO2, or mixed)
# TODO: create model type parameter so that we can ID model type this way instead of via strings in a list!
return calc_result
Expand Down
Loading

0 comments on commit 8d813e6

Please sign in to comment.