Extensions

Extensions related to MatPlotLib.

Mock module for Sandbox.

Assertions.

class BadGraphFeedback(plt_type, expected, actual, context=None, report=<pedal.core.report.Report object>, **kwargs)[source]
assert_plot(plt_type, data, context=None, special_comparison=None, **kwargs)[source]

Check whether a plot with the given plt_type and data exists. If the plot was found successfully, returns False. Otherwise, returns the feedback that was detected.

Parameters:
  • plt_type (str) – Either ‘line’, ‘hist’, or ‘scatter’

  • data (list) – The expected data to check in the plots. Could be a single list of numbers, or a pair of two lists (for scatter/line plots).

compare_data(plt_type, correct, given, special_comparison=None)[source]

Determines whether the given data matches any of the data found in the correct data. This handles plots of different types: if a histogram was plotted with the expected data for a line plot, it will return True.

Parameters:
  • plt_type (str) – The expected type of this plot

  • correct (List of Int or List of List of Int) – The expected data.

  • given (Dict) – The actual plotted data and information

  • special_comparison (callable) – A special comparison function to use between the data. If None, then will use the == operator.

Returns:

Whether the correct data was found in the given plot.

Return type:

bool

ensure_correct_plot(function_name, report=<pedal.core.report.Report object>, **kwargs)[source]

Checks that the given plot type was correctly called.

class ensure_show(*args, label=None, category=None, justification=None, fields=None, field_names=None, kind=None, title=None, message=None, message_template=None, else_message=None, else_message_template=None, priority=None, valence=None, location=None, score=None, correct=None, muted=None, unscored=None, tool=None, version=None, author=None, tags=None, parent=None, report=<pedal.core.report.Report object>, delay_condition=False, activate=True, **kwargs)[source]

Verifies that the plt.show function was called.

condition()[source]

Detect if this feedback is present in the code. Defaults to true through the activate parameter.

Returns:

Whether this feedback’s condition was detected.

Return type:

bool

get_plots(report=<pedal.core.report.Report object>)[source]

Retrieves any plots made by the user. The general structure is as follows:

class no_plt(plt_type, expected, actual, context=None, report=<pedal.core.report.Report object>, **kwargs)[source]
class other_plt(plt_type, expected, actual, context=None, report=<pedal.core.report.Report object>, **kwargs)[source]
class plt_rename_err(*args, label=None, category=None, justification=None, fields=None, field_names=None, kind=None, title=None, message=None, message_template=None, else_message=None, else_message_template=None, priority=None, valence=None, location=None, score=None, correct=None, muted=None, unscored=None, tool=None, version=None, author=None, tags=None, parent=None, report=<pedal.core.report.Report object>, delay_condition=False, activate=True, **kwargs)[source]
condition()[source]

Detect if this feedback is present in the code. Defaults to true through the activate parameter.

Returns:

Whether this feedback’s condition was detected.

Return type:

bool

class plt_wrong_import(*args, label=None, category=None, justification=None, fields=None, field_names=None, kind=None, title=None, message=None, message_template=None, else_message=None, else_message_template=None, priority=None, valence=None, location=None, score=None, correct=None, muted=None, unscored=None, tool=None, version=None, author=None, tags=None, parent=None, report=<pedal.core.report.Report object>, delay_condition=False, activate=True, **kwargs)[source]
condition()[source]

Detect if this feedback is present in the code. Defaults to true through the activate parameter.

Returns:

Whether this feedback’s condition was detected.

Return type:

bool

prevent_incorrect_plt(**kwargs)[source]

Confirms that matplotlib.pyplot is being imported correctly.

class wrong_plt_data(plt_type, expected, actual, context=None, report=<pedal.core.report.Report object>, **kwargs)[source]
class wrong_plt_type(plt_type, expected, actual, context=None, report=<pedal.core.report.Report object>, **kwargs)[source]

Extensions related to built-in Turtle library.

Mock Module for Sandbox.