From 04693c81a427357863129728e6150870f31b1a34 Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Tue, 19 Nov 2024 16:34:46 -0600 Subject: [PATCH 1/6] abstracting plotting --- .github/workflows/CI_Tests.yml | 12 ++ .github/workflows/pep8_autoformat.yml | 2 +- src/acom_music_box/__init__.py | 1 + src/acom_music_box/data_output.py | 7 -- src/acom_music_box/main.py | 81 +------------ src/acom_music_box/plot_output.py | 168 ++++++++++++++++++++++++++ tests/unit/test_plot_output.py | 56 +++++++++ 7 files changed, 242 insertions(+), 85 deletions(-) create mode 100644 src/acom_music_box/plot_output.py create mode 100644 tests/unit/test_plot_output.py diff --git a/.github/workflows/CI_Tests.yml b/.github/workflows/CI_Tests.yml index fded29d1..257a8e0b 100644 --- a/.github/workflows/CI_Tests.yml +++ b/.github/workflows/CI_Tests.yml @@ -32,6 +32,18 @@ jobs: - name: Run pytest run: pytest + - name: Install gnuplot + if: runner.os == 'ubuntu-latest' + run: sudo apt-get install gnuplot + + - name: Install gnuplot + if: runner.os == 'macos-latest' + run: brew install gnuplot + + - name: Install gnuplot + if: runner.os == 'windows-latest' + run: choco install gnuplot + - name: Run the smoke tests run: | music_box -c src/acom_music_box/examples/configs/analytical/my_config.json -o output.csv diff --git a/.github/workflows/pep8_autoformat.yml b/.github/workflows/pep8_autoformat.yml index 33280f10..39528bfe 100644 --- a/.github/workflows/pep8_autoformat.yml +++ b/.github/workflows/pep8_autoformat.yml @@ -15,7 +15,7 @@ jobs: - name: autopep8 uses: peter-evans/autopep8@v2 with: - args: --recursive --in-place --aggressive --aggressive --max-line-length 180 . + args: --recursive --in-place --aggressive --aggressive --max-line-length 180 --indent-size=2 . - name: Check for changes id: check-changes diff --git a/src/acom_music_box/__init__.py b/src/acom_music_box/__init__.py index 25aba61e..83ba0d5b 100644 --- a/src/acom_music_box/__init__.py +++ b/src/acom_music_box/__init__.py @@ -14,3 +14,4 @@ from .music_box import MusicBox from .examples import Examples from .data_output import DataOutput +from .plot_output import PlotOutput diff --git a/src/acom_music_box/data_output.py b/src/acom_music_box/data_output.py index 227f01f5..3847e681 100644 --- a/src/acom_music_box/data_output.py +++ b/src/acom_music_box/data_output.py @@ -14,13 +14,6 @@ class DataOutput: This class manages file paths, unit mappings, and data output formats based on the provided arguments, ensuring valid paths and creating necessary directories. - Parameters - ---------- - df : pandas.DataFrame - The DataFrame containing the data to output. - args : argparse.Namespace - Arguments specifying output path, format, and additional options. - Attributes ---------- df : pandas.DataFrame diff --git a/src/acom_music_box/main.py b/src/acom_music_box/main.py index fc83ade9..f5dfba3b 100644 --- a/src/acom_music_box/main.py +++ b/src/acom_music_box/main.py @@ -3,13 +3,8 @@ import datetime import logging import os -import subprocess import sys -import tempfile -import matplotlib.pyplot as plt -import mplcursors -from acom_music_box import MusicBox, Examples, __version__, DataOutput - +from acom_music_box import MusicBox, Examples, __version__, DataOutput, PlotOutput def format_examples_help(examples): return '\n'.join(f"{e.short_name}: {e.description}" for e in examples) @@ -98,69 +93,6 @@ def setup_logging(verbosity, color_output): logging.basicConfig(level=log_level, handlers=[console_handler]) -def plot_with_gnuplot(data, species_list): - # Prepare columns and data for plotting - columns = ['time'] + species_list - data_to_plot = data[columns] - - data_csv = data_to_plot.to_csv(index=False) - - try: - with tempfile.NamedTemporaryFile(delete=False, suffix='.csv') as data_file: - data_file.write(data_csv.encode()) - data_file_path = data_file.name - - plot_commands = ',\n\t'.join( - f"'{data_file_path}' using 1:{i+2} with lines title '{species}'" for i, - species in enumerate(species_list)) - - gnuplot_command = f""" - set datafile separator ","; - set terminal dumb size 120,25; - set xlabel 'Time'; - set ylabel 'Value'; - set title 'Time vs Species'; - plot {plot_commands} - """ - - subprocess.run(['gnuplot', '-e', gnuplot_command], check=True) - except FileNotFoundError: - logging.critical("gnuplot is not installed. Skipping plotting.") - except subprocess.CalledProcessError as e: - logging.error(f"Error occurred while plotting: {e}") - finally: - # Clean up the temporary file - if data_file_path: - os.remove(data_file_path) - - -def plot_with_matplotlib(data, species_list): - # Prepare columns and data for plotting - indexed = data.set_index('time') - - fig, ax = plt.subplots() - indexed[species_list].plot(ax=ax) - - ax.set(xlabel='Time [s]', ylabel='Concentration [mol m-3]', title='Time vs Species') - - ax.spines[:].set_visible(False) - ax.spines['left'].set_visible(True) - ax.spines['bottom'].set_visible(True) - - ax.grid(alpha=0.5) - ax.legend() - - # Enable interactive data cursors with hover functionality - cursor = mplcursors.cursor(hover=True) - - # Customize the annotation format - @cursor.connect("add") - def on_add(sel): - sel.annotation.set_text(f'Time: {sel.target[0]:.2f}\nConcentration: {sel.target[1]:1.2e}') - - plt.show() - - def main(): start = datetime.datetime.now() @@ -181,8 +113,6 @@ def main(): else: musicBoxConfigFile = args.config - musicBoxOutputPath = args.output - plot_species_list = args.plot.split(',') if args.plot else None if not musicBoxConfigFile: @@ -202,11 +132,9 @@ def main(): dataOutput = DataOutput(result, args) dataOutput.output() - if plot_species_list: - if args.plot_tool == 'gnuplot': - plot_with_gnuplot(result, plot_species_list) - elif args.plot_tool == 'matplotlib': - plot_with_matplotlib(result, plot_species_list) + # Create an instance of PlotOutput + plotOutput = PlotOutput(result, args) + plotOutput.plot() end = datetime.datetime.now() logger.info(f"End time: {end}") @@ -214,6 +142,5 @@ def main(): sys.exit(0) - if __name__ == "__main__": main() diff --git a/src/acom_music_box/plot_output.py b/src/acom_music_box/plot_output.py new file mode 100644 index 00000000..b2dc3ee3 --- /dev/null +++ b/src/acom_music_box/plot_output.py @@ -0,0 +1,168 @@ +import logging +import matplotlib.pyplot as plt +import mplcursors +import subprocess +import os +import tempfile + +logger = logging.getLogger(__name__) + +class PlotOutput: + """ + A class to handle plotting operations for a DataFrame, including plotting species + concentrations over time using gnuplot or matplotlib. + + This class manages the plotting tool, species list, and data output formats based on + the provided arguments, ensuring valid paths and creating necessary directories. + + Attributes + ---------- + df : pandas.DataFrame + The DataFrame to be plotted. + args : argparse.Namespace + Command-line arguments or configurations specifying plot options. + species_list : list + A list of species to plot. + + Examples + -------- + >>> import pandas as pd + >>> from argparse import Namespace + >>> df = pd.DataFrame({ + ... 'time.s': [0, 1, 2], + ... 'CONC.A.mol m-3': [1, 2, 3], + ... 'CONC.B.mol m-3': [4, 5, 6], + ... 'CONC.C.mol m-3': [7, 8, 9] + ... }) + >>> args = Namespace(plot='CONC.A,CONC.B', plot_tool='matplotlib') + >>> plot_output = PlotOutput(df, args) + >>> plot_output.plot() + """ + + def __init__(self, df, args): + """ + Initialize the PlotOutput class with a DataFrame and configuration arguments. + + Parameters + ---------- + df : pandas.DataFrame + The DataFrame containing the data to be output. + args : argparse.Namespace + Arguments specifying the plot configuration, such as plot tool and species list. + """ + + self.df = df + self.args = args + self.species_list = self._format_species_list(self.args.plot.split(',') if self.args.plot else None) + + + def _format_species_list(self, species_list): + """ + Format the species list for plotting. + + This method formats the species list for plotting by adding the 'CONC.' prefix + and '.mol m-3' suffix to each species name if not already present. + + Parameters + ---------- + species_list : list + A list of species to plot. + + Returns + ------- + list + A formatted list of species for plotting. + """ + + plot_list = None + if species_list is not None: + plot_list = [] + for species in species_list: + species = species.strip() + if 'CONC.' not in species: + species = f'CONC.{species}' + if 'mol m-3' not in species: + species = f'{species}.mol m-3' + plot_list.append(species) + + return plot_list + + def _plot_with_gnuplot(self): + """ + Plot the specified species using gnuplot. + """ + # Prepare columns and data for plotting + columns = ['time.s'] + self.species_list + data_to_plot = self.df[columns] + + data_csv = data_to_plot.to_csv(index=False) + + try: + with tempfile.NamedTemporaryFile(suffix='.csv', mode='w+', delete=True) as data_file: + data_file.write(data_csv) + data_file.flush() + data_file_path = data_file.name + + plot_commands = ',\n\t'.join( + f"'{data_file_path}' using 1:{i+2} with lines title '{species}'" for i, + species in enumerate(self.species_list)) + + gnuplot_command = f""" + set datafile separator ","; + set terminal dumb size 120,25; + set xlabel 'Time'; + set ylabel 'Value'; + set title 'Time vs Species'; + plot {plot_commands} + """ + + subprocess.run(['gnuplot', '-e', gnuplot_command], check=True) + except FileNotFoundError as e: + logging.critical("gnuplot is not installed. Skipping plotting.") + raise e + except subprocess.CalledProcessError as e: + logging.error(f"Error occurred while plotting: {e}") + raise e + + def _plot_with_matplotlib(self): + """ + Plot the specified species using matplotlib. + """ + + indexed = self.df.set_index('time.s') + + fig, ax = plt.subplots() + indexed[self.species_list].plot(ax=ax) + + ax.set(xlabel='Time [s]', ylabel='Concentration [mol m-3]', title='Time vs Species') + + ax.spines[:].set_visible(False) + ax.spines['left'].set_visible(True) + ax.spines['bottom'].set_visible(True) + + ax.grid(alpha=0.5) + ax.legend() + + # Enable interactive data cursors with hover functionality + cursor = mplcursors.cursor(hover=True) + + # Customize the annotation format + @cursor.connect("add") + def on_add(sel): + sel.annotation.set_text(f'Time: {sel.target[0]:.2f}\nConcentration: {sel.target[1]:1.2e}') + + plt.show() + + def plot(self): + """ + Plot the specified species using the selected plotting tool. + """ + + if self.species_list is None: + logger.debug("No species provided for plotting.") + return + + if self.args.plot_tool == 'gnuplot': + self._plot_with_gnuplot() + else: + self._plot_with_matplotlib() \ No newline at end of file diff --git a/tests/unit/test_plot_output.py b/tests/unit/test_plot_output.py new file mode 100644 index 00000000..7f9089a0 --- /dev/null +++ b/tests/unit/test_plot_output.py @@ -0,0 +1,56 @@ +import unittest +import pandas as pd +import shutil +from argparse import Namespace +import matplotlib +import subprocess + +matplotlib.use('Agg') # Use a non-interactive backend + +from acom_music_box.plot_output import PlotOutput + +class TestPlotOutput(unittest.TestCase): + + def setUp(self): + # Set up a sample DataFrame and arguments for testing + self.df = pd.DataFrame({ + 'time.s': [0, 1, 2], + 'CONC.A.mol m-3': [1, 2, 3], + 'CONC.B.mol m-3': [4, 5, 6], + 'CONC.C.mol m-3': [7, 8, 9] + }) + + def test_format_species_list(self): + args = Namespace(plot='A,B', plot_tool='matplotlib') + plot_output = PlotOutput(self.df, args) + expected_list = ['CONC.A.mol m-3', 'CONC.B.mol m-3'] + self.assertEqual(plot_output.species_list, expected_list) + + args = Namespace(plot='CONC.A,CONC.B', plot_tool='matplotlib') + plot_output = PlotOutput(self.df, args) + self.assertEqual(plot_output.species_list, expected_list) + + args = Namespace(plot='CONC.A.mol m-3,CONC.B.mol m-3', plot_tool='matplotlib') + plot_output = PlotOutput(self.df, args) + self.assertEqual(plot_output.species_list, expected_list) + + args = Namespace(plot='A.mol m-3,B.mol m-3', plot_tool='matplotlib') + plot_output = PlotOutput(self.df, args) + self.assertEqual(plot_output.species_list, expected_list) + + def test_plot_with_gnuplot(self): + args = Namespace(plot='A,B', plot_tool='gnuplot') + plot_output = PlotOutput(self.df, args) + if shutil.which('gnuplot') is None: + with self.assertRaises(FileNotFoundError): + plot_output.plot() + else: + plot_output.plot() + + def test_plot_with_matplotlib(self): + args = Namespace(plot='A,B', plot_tool='matplotlib') + plot_output = PlotOutput(self.df, args) + plot_output.plot() + +if __name__ == '__main__': + unittest.main() \ No newline at end of file From ff8853a4cf94c9f7b6e95891dc4c3aecf4f5e4a5 Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Thu, 21 Nov 2024 14:26:11 -0600 Subject: [PATCH 2/6] moving plotting code to its own file, correcting data output, readme --- README.md | 23 ++++++++++++++----- src/acom_music_box/data_output.py | 19 ++++++++------- src/acom_music_box/plot_output.py | 12 ++++------ .../test_executable_data_output.py | 7 ++++++ tests/unit/test_data_output.py | 8 +++---- tests/unit/test_plot_output.py | 18 ++++----------- 6 files changed, 47 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 4e1cf4a5..18a10e7e 100644 --- a/README.md +++ b/README.md @@ -32,13 +32,13 @@ Run an example. Notice that the output, in csv format, is printed to the termina music_box -e Chapman ``` -Output can be saved to a file in csv file when no `--output-format` is passed +Output can be saved to a csv file and printed to the terminal. ``` music_box -e Chapman -o output.csv ``` -Output can be saved to a file as csv file when `--output-format` csv is passed +Output can be saved to a csv file and the terminal output can be suppressed by specifying the `--output-format` ``` music_box --output-format csv -e Chapman -o output.csv @@ -50,13 +50,13 @@ Output can be saved to a file as netcdf file when `--output-format` netcdf is pa music_box --output-format netcdf -e Chapman -o output.nc ``` -Output can be saved to a file in csv file to output.csv when no output path is given but `--output-format` is csv +Output can be saved to a file in csv format when a filename is not specified. In this case a timestamped csv file is made ``` music_box --output-format csv -e Chapman ``` -Output can be saved to a file in netcdf file to output.nc when no output path is given but `--output-format` is netcdf +Output can be saved to a file in netcdf format when a filename is not specified. In this case a timestamped netcdf file is made ``` music_box --output-format netcdf -e Chapman @@ -68,10 +68,21 @@ You can also run your own configuration music_box -c my_config.json ``` -And, if you have gnuplot installed, some basic plots can be made to show some resulting concentrations +## Plotting +Some basic plots can be made to show concentrations throughout the simulation + +### matplotlib + +``` +music_box -e Chapman -o output.csv --plot O1D +``` + +### gnuplot +If you want ascii plots (maybe you're running over ssh and can't view a graphical window), you can set +the plot tool to gnuplo (`--plot-tool gnuplot`) to view some output ``` -music_box -e Chapman -o output.csv --color-output --plot CONC.O1D +music_box -e Chapman -o output.csv --plot O1D --plot-tool gnuplot ``` # Development and Contributing diff --git a/src/acom_music_box/data_output.py b/src/acom_music_box/data_output.py index 3847e681..46f20500 100644 --- a/src/acom_music_box/data_output.py +++ b/src/acom_music_box/data_output.py @@ -57,12 +57,12 @@ def __init__(self, df, args): - output_format : str, optional Format of the output file, either 'csv' or 'netcdf'. Defaults to 'csv'. """ - self.df = df + self.df = df.copy(deep=True) self.args = args self.unit_mapping = { 'ENV.temperature': 'K', 'ENV.pressure': 'Pa', - 'ENV.number_density_air': 'kg -m3', + 'ENV.number_density_air': 'kg m-3', 'time': 's' } @@ -103,7 +103,7 @@ def _convert_to_netcdf(self): ds['ENV.temperature'].attrs = {'units': 'K'} ds['ENV.pressure'].attrs = {'units': 'Pa'} - ds['ENV.number_density_air'].attrs = {'units': 'kg -m3'} + ds['ENV.number_density_air'].attrs = {'units': 'kg m-3'} ds['time'].attrs = {'units': 's'} ds.to_netcdf(self.args.output) @@ -139,11 +139,10 @@ def output(self): # Determine output type and call the respective method if self.args.output_format is None or self.args.output_format == 'terminal': self._output_terminal() - elif self.args.output_format is None or self.args.output_format == 'csv': + + # Even if we are printing to the terminal, we still allow output to be written to csv if an output path is provided + if (self.args.output_format == 'csv') or (self.args.output is not None and self.args.output_format == 'terminal'): self._output_csv() - elif self.args.output_format == 'netcdf': - self._output_netcdf() - else: - error = f"Unsupported output format: {self.args.output_format}" - logger.error(error) - raise ValueError(error) + + if self.args.output_format == 'netcdf': + self._output_netcdf() \ No newline at end of file diff --git a/src/acom_music_box/plot_output.py b/src/acom_music_box/plot_output.py index b2dc3ee3..cef9ac69 100644 --- a/src/acom_music_box/plot_output.py +++ b/src/acom_music_box/plot_output.py @@ -29,7 +29,7 @@ class PlotOutput: >>> import pandas as pd >>> from argparse import Namespace >>> df = pd.DataFrame({ - ... 'time.s': [0, 1, 2], + ... 'time': [0, 1, 2], ... 'CONC.A.mol m-3': [1, 2, 3], ... 'CONC.B.mol m-3': [4, 5, 6], ... 'CONC.C.mol m-3': [7, 8, 9] @@ -51,7 +51,7 @@ def __init__(self, df, args): Arguments specifying the plot configuration, such as plot tool and species list. """ - self.df = df + self.df = df.copy(deep=True) self.args = args self.species_list = self._format_species_list(self.args.plot.split(',') if self.args.plot else None) @@ -61,7 +61,7 @@ def _format_species_list(self, species_list): Format the species list for plotting. This method formats the species list for plotting by adding the 'CONC.' prefix - and '.mol m-3' suffix to each species name if not already present. + to each species name if it is not already present. Parameters ---------- @@ -81,8 +81,6 @@ def _format_species_list(self, species_list): species = species.strip() if 'CONC.' not in species: species = f'CONC.{species}' - if 'mol m-3' not in species: - species = f'{species}.mol m-3' plot_list.append(species) return plot_list @@ -92,7 +90,7 @@ def _plot_with_gnuplot(self): Plot the specified species using gnuplot. """ # Prepare columns and data for plotting - columns = ['time.s'] + self.species_list + columns = ['time'] + self.species_list data_to_plot = self.df[columns] data_csv = data_to_plot.to_csv(index=False) @@ -129,7 +127,7 @@ def _plot_with_matplotlib(self): Plot the specified species using matplotlib. """ - indexed = self.df.set_index('time.s') + indexed = self.df.set_index('time') fig, ax = plt.subplots() indexed[self.species_list].plot(ax=ax) diff --git a/tests/integration/test_executable_data_output.py b/tests/integration/test_executable_data_output.py index 42ae5530..1bdba48e 100644 --- a/tests/integration/test_executable_data_output.py +++ b/tests/integration/test_executable_data_output.py @@ -4,6 +4,8 @@ import pytest import tempfile +from acom_music_box import Examples + @pytest.fixture def temp_dir(): @@ -58,3 +60,8 @@ def test_create_directory_and_timestamped_netcdf(temp_dir): os.makedirs(os.path.join(temp_dir, "results"), exist_ok=True) subprocess.run(['music_box', '-e', 'Analytical', '--output-format', 'netcdf', '-o', 'results/'], cwd=temp_dir) assert glob.glob(os.path.join(temp_dir, "results/music_box_*.nc")) + + +def test_run_configuration_file(temp_dir): + result = subprocess.run(['music_box', '-c', Examples.Analytical.path], capture_output=True, text=True, cwd=temp_dir) + assert result.returncode == 0 \ No newline at end of file diff --git a/tests/unit/test_data_output.py b/tests/unit/test_data_output.py index ac7648fb..452e5864 100644 --- a/tests/unit/test_data_output.py +++ b/tests/unit/test_data_output.py @@ -35,7 +35,7 @@ def test_append_units_to_columns(self): args = Namespace(output=None) data_output = DataOutput(self.df, args) data_output._append_units_to_columns() - expected_columns = ['ENV.temperature.K', 'ENV.pressure.Pa', 'ENV.number_density_air.kg -m3', 'time.s'] + expected_columns = ['ENV.temperature.K', 'ENV.pressure.Pa', 'ENV.number_density_air.kg m-3', 'time.s'] self.assertEqual(list(data_output.df.columns), expected_columns) def test_convert_to_netcdf(self): @@ -48,7 +48,7 @@ def test_convert_to_netcdf(self): ds = xr.open_dataset(self.netcdf_path) self.assertEqual(ds['ENV.temperature'].attrs['units'], 'K') self.assertEqual(ds['ENV.pressure'].attrs['units'], 'Pa') - self.assertEqual(ds['ENV.number_density_air'].attrs['units'], 'kg -m3') + self.assertEqual(ds['ENV.number_density_air'].attrs['units'], 'kg m-3') self.assertEqual(ds['time'].attrs['units'], 's') ds.close() @@ -60,7 +60,7 @@ def test_output_csv(self): # Check the contents of the CSV file output_df = pd.read_csv(self.csv_path) - expected_columns = ['ENV.temperature.K', 'ENV.pressure.Pa', 'ENV.number_density_air.kg -m3', 'time.s'] + expected_columns = ['ENV.temperature.K', 'ENV.pressure.Pa', 'ENV.number_density_air.kg m-3', 'time.s'] self.assertEqual(list(output_df.columns), expected_columns) def test_output_netcdf(self): @@ -73,7 +73,7 @@ def test_output_netcdf(self): ds = xr.open_dataset(self.netcdf_path) self.assertEqual(ds['ENV.temperature'].attrs['units'], 'K') self.assertEqual(ds['ENV.pressure'].attrs['units'], 'Pa') - self.assertEqual(ds['ENV.number_density_air'].attrs['units'], 'kg -m3') + self.assertEqual(ds['ENV.number_density_air'].attrs['units'], 'kg m-3') self.assertEqual(ds['time'].attrs['units'], 's') ds.close() diff --git a/tests/unit/test_plot_output.py b/tests/unit/test_plot_output.py index 7f9089a0..8b250515 100644 --- a/tests/unit/test_plot_output.py +++ b/tests/unit/test_plot_output.py @@ -14,30 +14,22 @@ class TestPlotOutput(unittest.TestCase): def setUp(self): # Set up a sample DataFrame and arguments for testing self.df = pd.DataFrame({ - 'time.s': [0, 1, 2], - 'CONC.A.mol m-3': [1, 2, 3], - 'CONC.B.mol m-3': [4, 5, 6], - 'CONC.C.mol m-3': [7, 8, 9] + 'time': [0, 1, 2], + 'CONC.A': [1, 2, 3], + 'CONC.B': [4, 5, 6], + 'CONC.C': [7, 8, 9] }) def test_format_species_list(self): args = Namespace(plot='A,B', plot_tool='matplotlib') plot_output = PlotOutput(self.df, args) - expected_list = ['CONC.A.mol m-3', 'CONC.B.mol m-3'] + expected_list = ['CONC.A', 'CONC.B'] self.assertEqual(plot_output.species_list, expected_list) args = Namespace(plot='CONC.A,CONC.B', plot_tool='matplotlib') plot_output = PlotOutput(self.df, args) self.assertEqual(plot_output.species_list, expected_list) - args = Namespace(plot='CONC.A.mol m-3,CONC.B.mol m-3', plot_tool='matplotlib') - plot_output = PlotOutput(self.df, args) - self.assertEqual(plot_output.species_list, expected_list) - - args = Namespace(plot='A.mol m-3,B.mol m-3', plot_tool='matplotlib') - plot_output = PlotOutput(self.df, args) - self.assertEqual(plot_output.species_list, expected_list) - def test_plot_with_gnuplot(self): args = Namespace(plot='A,B', plot_tool='gnuplot') plot_output = PlotOutput(self.df, args) From 2ab50f6b2f0b04c9183f7f89f955eb24e28c474d Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Sat, 23 Nov 2024 13:55:03 -0600 Subject: [PATCH 3/6] correcting ci install for gnuplot --- .github/workflows/CI_Tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI_Tests.yml b/.github/workflows/CI_Tests.yml index 2b142baa..252dbfc9 100644 --- a/.github/workflows/CI_Tests.yml +++ b/.github/workflows/CI_Tests.yml @@ -33,15 +33,15 @@ jobs: run: pytest --cov src/ - name: Install gnuplot - if: runner.os == 'ubuntu-latest' + if: runner.os == 'Ubuntu' run: sudo apt-get install gnuplot - name: Install gnuplot - if: runner.os == 'macos-latest' + if: runner.os == 'macOS' run: brew install gnuplot - name: Install gnuplot - if: runner.os == 'windows-latest' + if: runner.os == 'Windows' run: choco install gnuplot - name: Upload coverage reports to codecov From b7ffc9a7ada9c43ede380bb7f1db2b11d66836af Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Sat, 23 Nov 2024 13:57:29 -0600 Subject: [PATCH 4/6] fixing gnuplot install for linux --- .github/workflows/CI_Tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI_Tests.yml b/.github/workflows/CI_Tests.yml index 252dbfc9..75b3e7fb 100644 --- a/.github/workflows/CI_Tests.yml +++ b/.github/workflows/CI_Tests.yml @@ -33,7 +33,7 @@ jobs: run: pytest --cov src/ - name: Install gnuplot - if: runner.os == 'Ubuntu' + if: runner.os == 'Linux' run: sudo apt-get install gnuplot - name: Install gnuplot From c129388f6d5eea2f077dcb30b8d2bcda50263cae Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Sat, 23 Nov 2024 13:59:52 -0600 Subject: [PATCH 5/6] running tests after installing gnuplot --- .github/workflows/CI_Tests.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/CI_Tests.yml b/.github/workflows/CI_Tests.yml index 75b3e7fb..be4d4f6e 100644 --- a/.github/workflows/CI_Tests.yml +++ b/.github/workflows/CI_Tests.yml @@ -29,9 +29,6 @@ jobs: - name: Install this package run: pip install -e '.[dev]' - - name: Run tests and generate coverage reports - run: pytest --cov src/ - - name: Install gnuplot if: runner.os == 'Linux' run: sudo apt-get install gnuplot @@ -43,6 +40,9 @@ jobs: - name: Install gnuplot if: runner.os == 'Windows' run: choco install gnuplot + + - name: Run tests and generate coverage reports + run: pytest --cov src/ - name: Upload coverage reports to codecov if: runner.os == 'Linux' From 90380caf6d6da0b3276c97b77083f6369e2d08c6 Mon Sep 17 00:00:00 2001 From: Kyle Shores Date: Mon, 2 Dec 2024 13:08:52 -0600 Subject: [PATCH 6/6] Update pep8_autoformat.yml --- .github/workflows/pep8_autoformat.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pep8_autoformat.yml b/.github/workflows/pep8_autoformat.yml index 85f4f282..010849d7 100644 --- a/.github/workflows/pep8_autoformat.yml +++ b/.github/workflows/pep8_autoformat.yml @@ -15,7 +15,7 @@ jobs: - name: autopep8 uses: peter-evans/autopep8@v2 with: - args: --recursive --in-place --aggressive --aggressive --max-line-length 180 --indent-size=2 . + args: --recursive --in-place --aggressive --max-line-length 180 --indent-size=2 . - name: Check for changes id: check-changes @@ -42,4 +42,4 @@ jobs: commit-message: "Auto-format code using autopep8" title: "Auto-format code by autopep8" body: "This is an auto-generated PR with fixes by autopep8." - branch: main-autopep8 \ No newline at end of file + branch: main-autopep8