From 6f54aea1b60a1502ac635ffe7f59e57263bf22e2 Mon Sep 17 00:00:00 2001 From: Ryan LaRocque Date: Mon, 16 Mar 2020 02:04:41 -0600 Subject: [PATCH 01/11] Added tests for timeseries module. --- matplotcheck/base.py | 42 +++--- matplotcheck/tests/test_timeseries_module.py | 143 +++++++++++++++++-- 2 files changed, 151 insertions(+), 34 deletions(-) diff --git a/matplotcheck/base.py b/matplotcheck/base.py index 29be8d9b..b5684dd9 100644 --- a/matplotcheck/base.py +++ b/matplotcheck/base.py @@ -8,7 +8,6 @@ """ import numpy as np -import matplotlib.dates as mdates import matplotlib from matplotlib.backend_bases import RendererBase import math @@ -762,7 +761,7 @@ def assert_no_legend_overlap(self, message="Legends overlap eachother"): """ BASIC PLOT DATA FUNCTIONS """ - def get_xy(self, points_only=False, xtime=False): + def get_xy(self, points_only=False): """Returns a pandas dataframe with columns "x" and "y" holding the x and y coords on Axes `ax` @@ -773,9 +772,6 @@ def get_xy(self, points_only=False, xtime=False): points_only : boolean Set ``True`` to check only points, set ``False`` to check all data on plot. - xtime : boolean - Set equal to True if the x axis of the plot contains datetime - values Returns ------- @@ -816,9 +812,6 @@ def get_xy(self, points_only=False, xtime=False): xy_data = xy_data[xy_data["x"] >= lims[0]] xy_data = xy_data[xy_data["x"] <= lims[1]].reset_index(drop=True) - # change to datetime dtype if needed - if xtime: - xy_data["x"] = mdates.num2date(xy_data["x"]) return xy_data def assert_xydata( @@ -827,7 +820,6 @@ def assert_xydata( xcol=None, ycol=None, points_only=False, - xtime=False, xlabels=False, tolerence=0, message="Incorrect data values", @@ -851,11 +843,6 @@ def assert_xydata( points_only : boolean, Set ``True`` to check only points, set ``False`` tp check all data on plot. - xtime : boolean - Set ``True`` if the a-axis contains datetime values. Matplotlib - converts datetime objects to seconds? This parameter will ensure - the provided x col values are converted if they are datetime - elements. xlabels : boolean Set ``True`` if using x axis labels rather than x data. Instead of comparing numbers in the x-column to expected, compares numbers or @@ -865,7 +852,8 @@ def assert_xydata( For example: Given a tolerance ``tolerence=0.1``, an expected value ``e``, and an actual value ``a``, this asserts ``abs(a - e) < (e * 0.1)``. (This uses `np.testing.assert_allclose` - with ``rtol=tolerence`` and ``atol=inf``.) + with ``rtol=tolerence`` and ``atol=inf``.) If using tolerance for + datetime data, units for tolerance will be in days. message : string The error message to be displayed if the xy-data does not match `xy_expected` @@ -901,7 +889,7 @@ def assert_xydata( xy_expected, xcol=xcol, ycol=ycol, message=message ) return - xy_data = self.get_xy(points_only=points_only, xtime=xtime) + xy_data = self.get_xy(points_only=points_only) # Make sure the data are sorted the same xy_data, xy_expected = ( @@ -910,8 +898,6 @@ def assert_xydata( ) if tolerence > 0: - if xtime: - raise ValueError("tolerance must be 0 with datetime on x-axis") np.testing.assert_allclose( xy_data["x"], xy_expected[xcol], @@ -929,17 +915,21 @@ def assert_xydata( """We use `assert_array_max_ulp()` to compare the two datasets because it is able to account for small errors in floating point numbers, and it scales nicely between extremely - small or large numbers. We catch this error and throw our own so - that we can use our own message.""" + small or large numbers. Because of the way that matplotlib stores + datetime data, this is essential for comparing high-precision + datetime data (i.e. millisecond or lower). + + We catch this error and throw our own so that we can use our own + message.""" try: np.testing.assert_array_max_ulp( - np.array(xy_data["x"]), np.array(xy_expected[xcol]) + np.array(xy_data["x"]), np.array(xy_expected[xcol]), 5 ) except AssertionError: raise AssertionError(message) try: np.testing.assert_array_max_ulp( - np.array(xy_data["y"]), np.array(xy_expected[ycol]) + np.array(xy_data["y"]), np.array(xy_expected[ycol]), 5 ) except AssertionError: raise AssertionError(message) @@ -1010,7 +1000,7 @@ def assert_xlabel_ydata( if x_is_numeric: try: np.testing.assert_array_max_ulp( - np.array(xy_data["x"]), np.array(xy_expected[xcol]) + np.array(xy_data["x"]), np.array(xy_expected[xcol]), 5 ) except AssertionError: raise AssertionError(message) @@ -1022,7 +1012,7 @@ def assert_xlabel_ydata( # Testing y-data try: np.testing.assert_array_max_ulp( - np.array(xy_data["y"]), np.array(xy_expected[ycol]) + np.array(xy_data["y"]), np.array(xy_expected[ycol]), 5 ) except AssertionError: raise AssertionError(message) @@ -1162,7 +1152,7 @@ def get_num_bins(self): overlapping or stacked histograms in the same `matplotlib.axis.Axis` object, then this returns the number of bins with unique edges. """ - x_data = self.get_xy(xtime=False)["x"] + x_data = self.get_xy()["x"] unique_x_data = list(set(x_data)) num_bins = len(unique_x_data) @@ -1206,7 +1196,7 @@ def get_bin_values(self): Int : The number of bins in the histogram""" - bin_values = self.get_xy(xtime=False)["y"].tolist() + bin_values = self.get_xy()["y"].tolist() return bin_values diff --git a/matplotcheck/tests/test_timeseries_module.py b/matplotcheck/tests/test_timeseries_module.py index b1be1448..dbfaf7c1 100644 --- a/matplotcheck/tests/test_timeseries_module.py +++ b/matplotcheck/tests/test_timeseries_module.py @@ -1,9 +1,136 @@ -''' -def test_assert_xydata_timeseries(pt_time_line_plt, pd_df_timeseries): - """Commenting this out for now as this requires a time series data object - this is failing because the time data needs to be in seconds like how - mpl saves it. """ - pt_time_line_plt.assert_xydata( - pd_df_timeseries, xcol='time', ycol='A', xtime=True +import pytest +from matplotcheck.timeseries import TimeSeriesTester +import matplotlib.pyplot as plt +import numpy as np +import pandas as pd + + +@pytest.fixture +def pd_df_timeseries(): + """Create a pandas dataframe for testing, with timeseries in one column""" + return pd.DataFrame( + { + "time": pd.date_range(start="1/1/2018", periods=100), + "A": np.random.randint(0, 100, size=100), + } ) -''' + + +@pytest.fixture +def pt_time_line_plt(pd_df_timeseries): + """Create timeseries line plot for testing""" + fig, ax = plt.subplots() + pd_df_timeseries.plot("time", "A", kind="line", ax=ax) + axis = plt.gca() + + return TimeSeriesTester(axis) + + +""" +matplotlib stores datetime data in a very... unique way. It stores everything +as the number of days since some epoch. If you plot a dataframe containing +datetime.datetime objects or pandas.Timestamp objects, it will convert it days +since epoch. Sometimes matplotlib chooses Jan 1, 1970 as the epoch. Other +times it chooses Jan 1, 0001. If your data contains time data (i.e. higher +precision than just dates), matplotlib will store it as fractional days since +epoch, down to millisecond precision (or whatever precision your data is in). +For datetime data between these epochs, sometimes it will choose to store it as +negative days since 1970, other times it will store it as positive days since +the year 0001. + +matplotlib DOES provide functions for converting data from this weird format +back to datetime.datetime or pandas.Timestamp. However, these functions +always assume that the 1970 epoch was used. + +matplotlib's documentation claims that negative values for datetime data are +not supported, and therefore data representing dates before 1970 are not +supported. However, matplotlib will happily plot data before 1970 and its +conversion functions will happily accept negative numbers and try to convert +them. + +As you might imagine, this presents a number of issues for comparing datetime +data. Most obviously, it gets unreliable when we have to guess which epoch +matplotlib chose to use. We have tried a few different methods here: different +ways of converting the data, converting using both epochs and comparing both, +etc. All of them were pretty messy. + +Additionally, there is the issue of floating point truncation error. matplotlib +stores this data with numpy.float64, which has 52 mantissa bits, or about 15 +base-10 digits of accuracy. Since the number of days since epoch is often in +the tens-of-thousands, this means that matplotlib may not be able to accurately +represent data with millisecond precision. (Basically, the datatype isn't able +to store such a huge number with such small precision.) The actual available +precision will depend on the dates being used and the epoch matplotlib chooses. + +So to solve these problems, we have done two things: + +First, we don't bother to try to convert from matplotlib's data ourselves. +Instead, we require that instructors provide the expected data in matplotlib's +format when using assert_xydata(). The easiest way for instructors to do this +is for them to plot the data themselves, create a matplotcheck object from it, +and then extract the data using get_xy(). One weird quirk is that matplotlib +seems to consistently choose the same epoch when plotting the same dataset. +(However, we are unable to predict which epoch this will be for a given +dataset, and matplotlib's conversion functions don't always choose the same +epoch as when the data is plotted.) This solves the problem of being able to +convert the data. + +Second, we use numpy.testing.assert_array_max_ulp() for comparing datetime data +(or any other type of numeric data). This method of comparison ensures that +floating-point roundoff error does not cause the assertion to erroneously fail. +However, this cannot prevent truncation error, and therefore cannot prevent a +loss of precision. Practically, what this means is that assert_xydata() cannot +tell the difference between times with differences of tens of milliseconds. If +it can't tell the difference, it will err on the side of passing. + +For more info about the issues we've faced with this, take a look at PR #185 +""" + + +def test_assert_xydata_timeseries(pt_time_line_plt): + """Tests that assert_xydata() correctly passes with matching timeseries + data.""" + data = pt_time_line_plt.get_xy() + pt_time_line_plt.assert_xydata(data, xcol="x", ycol="y") + + +def test_assert_xydata_timeseries_fails(pt_time_line_plt): + """Tests that assert_xydata() correctly fails without matching timeseries + data.""" + data = pt_time_line_plt.get_xy() + data.loc[0, "x"] = 100 + with pytest.raises(AssertionError, match="Incorrect data values"): + pt_time_line_plt.assert_xydata(data, xcol="x", ycol="y") + + +def test_assert_xydata_timeseries_truncation_error( + pt_time_line_plt, pd_df_timeseries +): + """Tests that assert_xydata() handles floating-point truncation error + gracefully for timeseries data.""" + + pt1 = pt_time_line_plt + + # Create second plottester object with slightly different time values + # The change in values here should be small enough that it gets truncated + # in matplotlib's conversion of datetime data + for i in range(len(pd_df_timeseries)): + pd_df_timeseries.loc[i, "time"] = pd_df_timeseries.loc[ + i, "time" + ] + pd.Timedelta(1) + fig, ax2 = plt.subplots() + pd_df_timeseries.plot("time", "A", kind="line", ax=ax2) + pt2 = TimeSeriesTester(ax2) + + # Test that the two datasets assert as equal + data1 = pt1.get_xy() + pt2.assert_xydata(data1, xcol="x", ycol="y") + + +def test_assert_xydata_timeseries_roundoff_error(pt_time_line_plt): + """Tests that assert_xydata() handles floating-point roundoff error + gracefully for timeseries data.""" + data = pt_time_line_plt.get_xy() + data.loc[0, "x"] = data.loc[0, "x"] + 0.00000000001 + + pt_time_line_plt.assert_xydata(data, xcol="x", ycol="y") From bfafa8ab0c8f0e78afe79717b4fefeda7b8ec83a Mon Sep 17 00:00:00 2001 From: Ryan LaRocque Date: Wed, 25 Mar 2020 23:19:33 -0600 Subject: [PATCH 02/11] Fixed a bug where assert_xydata() sometimes failed to compare numpy arrays when dtype was object --- matplotcheck/base.py | 46 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/matplotcheck/base.py b/matplotcheck/base.py index b5684dd9..100ed936 100644 --- a/matplotcheck/base.py +++ b/matplotcheck/base.py @@ -922,15 +922,57 @@ def assert_xydata( We catch this error and throw our own so that we can use our own message.""" try: + # np.testing.assert_array_max_ulp( + # np.array(xy_data["x"]), np.array(xy_expected[xcol]), 5 + # ) np.testing.assert_array_max_ulp( - np.array(xy_data["x"]), np.array(xy_expected[xcol]), 5 + xy_data["x"].to_numpy(dtype=np.float64), + xy_expected[xcol].to_numpy(dtype=np.float64), + 5, ) except AssertionError: raise AssertionError(message) + except TypeError: + string = ( + "????\n\n" + + "xy_data:\n" + + str(xy_data) + + "\n\nxy_expected:\n\n" + + str(xy_expected) + ) + string = ( + string + + "\n\n" + + str( + xy_data["x"] + .to_numpy(dtype=np.float64) + .astype(np.float64) + .dtype + ) + ) + string = ( + string + + "\n\n" + + str(xy_expected["x"].to_numpy(dtype=np.float64).dtype) + ) + string = ( + string + + "\n\n" + + str(type(xy_data["x"][0])) + + "\t" + + str(xy_expected["x"].dtype) + ) + raise AssertionError(string) try: + # np.testing.assert_array_max_ulp( + # np.array(xy_data["y"], np.array(xy_expected[ycol]), 5 + # ) np.testing.assert_array_max_ulp( - np.array(xy_data["y"]), np.array(xy_expected[ycol]), 5 + xy_data["y"].to_numpy(dtype=np.float64), + xy_expected[ycol].to_numpy(dtype=np.float64), + 5, ) + except AssertionError: raise AssertionError(message) From 5a53ad41128d33a374c995e4d569ba31e073e4e5 Mon Sep 17 00:00:00 2001 From: Ryan LaRocque Date: Wed, 25 Mar 2020 23:34:16 -0600 Subject: [PATCH 03/11] Changed behavior of assert_xydata() to display standard error message when xy_data and xy_expected do not have the same shape. --- matplotcheck/base.py | 45 ++++++++------------------------------------ 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/matplotcheck/base.py b/matplotcheck/base.py index 100ed936..bc6b7e7c 100644 --- a/matplotcheck/base.py +++ b/matplotcheck/base.py @@ -922,51 +922,18 @@ def assert_xydata( We catch this error and throw our own so that we can use our own message.""" try: - # np.testing.assert_array_max_ulp( - # np.array(xy_data["x"]), np.array(xy_expected[xcol]), 5 - # ) np.testing.assert_array_max_ulp( xy_data["x"].to_numpy(dtype=np.float64), xy_expected[xcol].to_numpy(dtype=np.float64), 5, ) except AssertionError: + # xy_data and xy_expected do not contain the same data + raise AssertionError(message) + except ValueError: + # xy_data and xy_expected do not have the same shape raise AssertionError(message) - except TypeError: - string = ( - "????\n\n" - + "xy_data:\n" - + str(xy_data) - + "\n\nxy_expected:\n\n" - + str(xy_expected) - ) - string = ( - string - + "\n\n" - + str( - xy_data["x"] - .to_numpy(dtype=np.float64) - .astype(np.float64) - .dtype - ) - ) - string = ( - string - + "\n\n" - + str(xy_expected["x"].to_numpy(dtype=np.float64).dtype) - ) - string = ( - string - + "\n\n" - + str(type(xy_data["x"][0])) - + "\t" - + str(xy_expected["x"].dtype) - ) - raise AssertionError(string) try: - # np.testing.assert_array_max_ulp( - # np.array(xy_data["y"], np.array(xy_expected[ycol]), 5 - # ) np.testing.assert_array_max_ulp( xy_data["y"].to_numpy(dtype=np.float64), xy_expected[ycol].to_numpy(dtype=np.float64), @@ -974,6 +941,10 @@ def assert_xydata( ) except AssertionError: + # xy_data and xy_expected do not contain the same data + raise AssertionError(message) + except ValueError: + # xy_data and xy_expected do not have the same shape raise AssertionError(message) def assert_xlabel_ydata( From 39ba37319e53e935ee9523bbeaebedf25c0a7b5b Mon Sep 17 00:00:00 2001 From: Leah Wasser Date: Mon, 6 Apr 2020 10:11:18 -0600 Subject: [PATCH 04/11] remove extensive docs within test file --- matplotcheck/tests/test_timeseries_module.py | 61 -------------------- 1 file changed, 61 deletions(-) diff --git a/matplotcheck/tests/test_timeseries_module.py b/matplotcheck/tests/test_timeseries_module.py index dbfaf7c1..5391ccf5 100644 --- a/matplotcheck/tests/test_timeseries_module.py +++ b/matplotcheck/tests/test_timeseries_module.py @@ -26,67 +26,6 @@ def pt_time_line_plt(pd_df_timeseries): return TimeSeriesTester(axis) -""" -matplotlib stores datetime data in a very... unique way. It stores everything -as the number of days since some epoch. If you plot a dataframe containing -datetime.datetime objects or pandas.Timestamp objects, it will convert it days -since epoch. Sometimes matplotlib chooses Jan 1, 1970 as the epoch. Other -times it chooses Jan 1, 0001. If your data contains time data (i.e. higher -precision than just dates), matplotlib will store it as fractional days since -epoch, down to millisecond precision (or whatever precision your data is in). -For datetime data between these epochs, sometimes it will choose to store it as -negative days since 1970, other times it will store it as positive days since -the year 0001. - -matplotlib DOES provide functions for converting data from this weird format -back to datetime.datetime or pandas.Timestamp. However, these functions -always assume that the 1970 epoch was used. - -matplotlib's documentation claims that negative values for datetime data are -not supported, and therefore data representing dates before 1970 are not -supported. However, matplotlib will happily plot data before 1970 and its -conversion functions will happily accept negative numbers and try to convert -them. - -As you might imagine, this presents a number of issues for comparing datetime -data. Most obviously, it gets unreliable when we have to guess which epoch -matplotlib chose to use. We have tried a few different methods here: different -ways of converting the data, converting using both epochs and comparing both, -etc. All of them were pretty messy. - -Additionally, there is the issue of floating point truncation error. matplotlib -stores this data with numpy.float64, which has 52 mantissa bits, or about 15 -base-10 digits of accuracy. Since the number of days since epoch is often in -the tens-of-thousands, this means that matplotlib may not be able to accurately -represent data with millisecond precision. (Basically, the datatype isn't able -to store such a huge number with such small precision.) The actual available -precision will depend on the dates being used and the epoch matplotlib chooses. - -So to solve these problems, we have done two things: - -First, we don't bother to try to convert from matplotlib's data ourselves. -Instead, we require that instructors provide the expected data in matplotlib's -format when using assert_xydata(). The easiest way for instructors to do this -is for them to plot the data themselves, create a matplotcheck object from it, -and then extract the data using get_xy(). One weird quirk is that matplotlib -seems to consistently choose the same epoch when plotting the same dataset. -(However, we are unable to predict which epoch this will be for a given -dataset, and matplotlib's conversion functions don't always choose the same -epoch as when the data is plotted.) This solves the problem of being able to -convert the data. - -Second, we use numpy.testing.assert_array_max_ulp() for comparing datetime data -(or any other type of numeric data). This method of comparison ensures that -floating-point roundoff error does not cause the assertion to erroneously fail. -However, this cannot prevent truncation error, and therefore cannot prevent a -loss of precision. Practically, what this means is that assert_xydata() cannot -tell the difference between times with differences of tens of milliseconds. If -it can't tell the difference, it will err on the side of passing. - -For more info about the issues we've faced with this, take a look at PR #185 -""" - - def test_assert_xydata_timeseries(pt_time_line_plt): """Tests that assert_xydata() correctly passes with matching timeseries data.""" From 1868034c40da4757650c7853d23799a53b0f9366 Mon Sep 17 00:00:00 2001 From: "Ryan (Marty) LaRocque" Date: Thu, 23 Apr 2020 12:47:13 -0600 Subject: [PATCH 05/11] Change handling of arrays of different shape from AssertionError to ValueError --- matplotcheck/base.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/matplotcheck/base.py b/matplotcheck/base.py index a5a1d480..e13bf54d 100644 --- a/matplotcheck/base.py +++ b/matplotcheck/base.py @@ -932,7 +932,9 @@ def assert_xydata( raise AssertionError(message) except ValueError: # xy_data and xy_expected do not have the same shape - raise AssertionError(message) + raise ValueError( + "xy_data and xy_expected do not have the same shape" + ) try: np.testing.assert_array_max_ulp( xy_data["y"].to_numpy(dtype=np.float64), From 5046a6855ff3f1e598cf133f4829bdabf8b617d9 Mon Sep 17 00:00:00 2001 From: "Ryan (Marty) LaRocque" Date: Thu, 23 Apr 2020 13:18:10 -0600 Subject: [PATCH 06/11] Updated Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 42bec8d7..77e8d766 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Created functions to test point geometries in VectorTester (@nkorinek, #176) * made `assert_string_contains()` accept correct strings with spaces in them (@nkorinek, #182) * added contributors file and updated README to remove that information (@nkorinek, #121) +* Improved handling of datasets with different shapes in base.assert_xy() (@ryla5068, #233) +* Bug fix for handling object datatypes in base.assert_xy() (@ryla5068, #232) ## [0.1.2] * Adding flake8 for format and other syntax issues! yay! (@lwasser, #195) From f33993f7ca7ed989cfeccd90e3e2f83b994ad80f Mon Sep 17 00:00:00 2001 From: Leah Wasser Date: Fri, 24 Apr 2020 13:28:41 -0600 Subject: [PATCH 07/11] Update matplotcheck/base.py Co-Authored-By: Nathan Korinek --- matplotcheck/base.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matplotcheck/base.py b/matplotcheck/base.py index e13bf54d..70c75257 100644 --- a/matplotcheck/base.py +++ b/matplotcheck/base.py @@ -919,8 +919,8 @@ def assert_xydata( datetime data, this is essential for comparing high-precision datetime data (i.e. millisecond or lower). - We catch this error and throw our own so that we can use our own - message.""" + We catch this error and raise our own that is more relevant to + the assertion we are running.""" try: np.testing.assert_array_max_ulp( xy_data["x"].to_numpy(dtype=np.float64), From 803597706d72ae527f25d1e4c07c3d81de645563 Mon Sep 17 00:00:00 2001 From: Leah Wasser Date: Mon, 27 Apr 2020 10:05:41 -0600 Subject: [PATCH 08/11] PEP 8 import order --- matplotcheck/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matplotcheck/base.py b/matplotcheck/base.py index 70c75257..76339929 100644 --- a/matplotcheck/base.py +++ b/matplotcheck/base.py @@ -13,8 +13,8 @@ import math from scipy import stats import pandas as pd -import geopandas as gpd import numbers +import geopandas as gpd class InvalidPlotError(Exception): From 3adf71381cd8560c51503c233e20cb961414a947 Mon Sep 17 00:00:00 2001 From: Leah Wasser Date: Mon, 27 Apr 2020 10:10:05 -0600 Subject: [PATCH 09/11] pep 8 imports fix --- matplotcheck/tests/test_timeseries_module.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/matplotcheck/tests/test_timeseries_module.py b/matplotcheck/tests/test_timeseries_module.py index 5391ccf5..e8179bf5 100644 --- a/matplotcheck/tests/test_timeseries_module.py +++ b/matplotcheck/tests/test_timeseries_module.py @@ -1,8 +1,8 @@ -import pytest -from matplotcheck.timeseries import TimeSeriesTester import matplotlib.pyplot as plt import numpy as np import pandas as pd +import pytest +from matplotcheck.timeseries import TimeSeriesTester @pytest.fixture From 473098a4802f9cc6d5b2717171fdd0c59e12d028 Mon Sep 17 00:00:00 2001 From: "Ryan (Marty) LaRocque" Date: Mon, 4 May 2020 02:04:11 -0600 Subject: [PATCH 10/11] Final changes --- matplotcheck/base.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/matplotcheck/base.py b/matplotcheck/base.py index 76339929..01dae52c 100644 --- a/matplotcheck/base.py +++ b/matplotcheck/base.py @@ -919,7 +919,7 @@ def assert_xydata( datetime data, this is essential for comparing high-precision datetime data (i.e. millisecond or lower). - We catch this error and raise our own that is more relevant to + We catch this error and raise our own that is more relevant to the assertion we are running.""" try: np.testing.assert_array_max_ulp( @@ -947,7 +947,9 @@ def assert_xydata( raise AssertionError(message) except ValueError: # xy_data and xy_expected do not have the same shape - raise AssertionError(message) + raise ValueError( + "xy_data and xy_expected do not have the same shape" + ) def assert_xlabel_ydata( self, xy_expected, xcol, ycol, message="Incorrect Data" From c3990da72f21764166d1ee298255867e3f99064e Mon Sep 17 00:00:00 2001 From: Leah Wasser Date: Thu, 7 May 2020 11:06:46 -0600 Subject: [PATCH 11/11] delete markdown changelog --- CHANGELOG.md | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 77e8d766..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,48 +0,0 @@ -# MatPlotCheck Release Notes - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] -* Added functions to get and assert the midpoint values of bins in a histogram (@nkorinek, #184) -* Created tests for the autograde module (@nkorinek, #105) -* Created tests for the vector module (@nkorinek, #209) -* Created functions to test point geometries in VectorTester (@nkorinek, #176) -* made `assert_string_contains()` accept correct strings with spaces in them (@nkorinek, #182) -* added contributors file and updated README to remove that information (@nkorinek, #121) -* Improved handling of datasets with different shapes in base.assert_xy() (@ryla5068, #233) -* Bug fix for handling object datatypes in base.assert_xy() (@ryla5068, #232) - -## [0.1.2] -* Adding flake8 for format and other syntax issues! yay! (@lwasser, #195) -* Created a vignette covering the testing of histograms (@ryla5068, #149) -* Created `get_plot_image()` function for the RasterTester object (@nkorinek, #192) -* Allowed `assert_polygons()` to accept GeoDataFrames and added tests (@nkorinek, #175) -* raster test inherits from vector to allow for multi layer plot testing (@lwasser, #75) - -## [0.1.1] -* Added test for bin heights of histograms (@ryla5068, #124) -* Added support for overlapping histograms in histogram tests (@ryla5068, #123) - -## [0.1.0] -* Created a vignette covering base plot tester functionality (@ryla5068, #122) -* fix pip version to ensure pyproj installs in black tox envt (@lwasser, #144) -* Changed `get_caption()` to return a string (@ryla5068, #125) -* Updated `assert_xlabel_ydata()` to support pulling text from x-labels (@ryla5068, #125) -* Fixed `assert_xydata()` incorrectly failing on some floating point numbers (@ryla5068, #124) -* Updated all string content assertions in base to use the same syntax (@ryla5068, #132) -* Moved tests for titles to `test_base_titles.py` (@ryla5068, #115) -* Created `test_base_data.py` for data tests (@ryla5068, #114) -* Added custom error messages to all assert functions in base module (@ryla5068, #106) -* Added all missing docstrings to base module and updated existing ones (@ryla5068, #102) -* Added significant test coverage to base module (@ryla5068, #101) -* Replaced references to EarthPy in CONTRIBUTING.rst (@ryla5068, #100) -* Add tests for raster module (@kysolvik, #32) -* Added tests for base module -- legend check methods (@kysolvik, #38) -* Added tests for base modules -- axis check methods (@kysolvik, #37) -* Add conftest.py to centralize pytest fixtures (@kysolvik, #35) -* Fix issue with pip 19.1 breaking appveyor build (@kysolvik, #46) -* Fix Python version mismatch in pre-commit hook vs dev environment (@kysolvik, #31) -* Adding cross platform builds to CI