Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/grading_math/sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ Sample real matrices of a specific shape and norm. (`RealMatrices` uses the Frob
>>> # Sample 3 by 2 real matrices with norm between 5 and 10
>>> sampler = RealMatrices(shape=[3, 2], norm=[5, 10])
>>> # the default is shape=[2, 2] and norm=[1, 5]
>>> RealMatrices()
>>> default_sampler = RealMatrices()
>>> default_sampler
RealMatrices({'norm': [1, 5], 'shape': (2, 2)})

```

Expand All @@ -105,6 +107,7 @@ Sample square matrices of a given dimension consisting of the identity matrix mu
>>> sampler = IdentityMatrixMultiples(dimension=3, sampler=[1, 3])
>>> # The default is dimension=2 and sampler=[1, 5]
>>> IdentityMatrixMultiples()
IdentityMatrixMultiples({'dimension': 2, 'sampler': RealInterval({'start': 1, 'stop': 5})})

```

Expand Down Expand Up @@ -187,4 +190,5 @@ Finally, if you want to generate a complex random function, simply set `complex=

```python
>>> functionsampler = RandomFunction(complex=True)

```
1 change: 1 addition & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ A few error messages serve only as warnings. For example, if you attempt to conf
>>> grader = FormulaGrader(variables=['pi'])
Traceback (most recent call last):
ConfigError: Warning: 'variables' contains entries '['pi']' which will override default values. If you intend to override defaults, you may suppress this warning by adding 'suppress_warnings=True' to the grader configuration.

```

As the warning message says, if you really want to override the default value of `'pi'` (not recommended!) then you can suppress this warning by setting `suppress_warnings=True`.
Expand Down
7 changes: 6 additions & 1 deletion mitxgraders/baseclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from __future__ import division
import numbers
import abc
import pprint
from voluptuous import Schema, Required, All, Any, Range, MultipleInvalid
from voluptuous.humanize import validate_with_humanized_errors as voluptuous_validate
from mitxgraders.version import __version__
Expand Down Expand Up @@ -48,7 +49,11 @@ def __init__(self, config=None, **kwargs):

def __repr__(self):
"""Printable representation of the object"""
return "{classname}({config})".format(classname=self.__class__.__name__, config=self.config)
# Among other things, pprint.pformat ensures the config dict has
# keys in alphabetical order
pretty_config = pprint.pformat(self.config)
return "{classname}({config})".format(classname=self.__class__.__name__,
config=pretty_config)

class AbstractGrader(ObjectWithSchema):
"""
Expand Down
4 changes: 2 additions & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[pytest]
addopts = --doctest-modules --cov=mitxgraders --cov-report=term-missing
testpaths = tests mitxgraders
addopts = --doctest-modules --cov=mitxgraders --cov-report=term-missing --doctest-glob='*.md'
testpaths = tests mitxgraders docs