From 5b219fd6aa36f58cc5313b259b6f098ccf35a2d1 Mon Sep 17 00:00:00 2001 From: Sterling Harper Date: Fri, 12 Aug 2016 11:32:31 -0500 Subject: [PATCH] Fix doc build for metaclassed Polynomials --- docs/source/conf.py | 3 +++ openmc/data/function.py | 13 +++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 4aa000f386..1baea2b03c 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -28,6 +28,9 @@ MOCK_MODULES = ['numpy', 'numpy.polynomial', 'numpy.polynomial.polynomial', 'h5py', 'pandas', 'opencg'] sys.modules.update((mod_name, MagicMock()) for mod_name in MOCK_MODULES) +import numpy as np +np.polynomial.Polynomial = MagicMock + # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the diff --git a/openmc/data/function.py b/openmc/data/function.py index 768250259f..88d27ce93d 100644 --- a/openmc/data/function.py +++ b/openmc/data/function.py @@ -1,6 +1,7 @@ from abc import ABCMeta, abstractmethod from collections import Iterable, Callable from numbers import Real, Integral +from six import with_metaclass import numpy as np @@ -10,14 +11,11 @@ INTERPOLATION_SCHEME = {1: 'histogram', 2: 'linear-linear', 3: 'linear-log', 4: 'log-linear', 5: 'log-log'} -class Function1D(object): +class Function1D(with_metaclass(ABCMeta, object)): """A function of one independent variable with HDF5 support.""" - def __init__(self): pass - - def __call__(self): - raise NotImplemented('Subclasses of Function1D should overwrite the ' - '__call__ and to_hdf5 methods') + @abstractmethod + def __call__(self): pass @abstractmethod def to_hdf5(self, group, name='xy'): @@ -31,8 +29,7 @@ class Function1D(object): Name of the dataset to create """ - raise NotImplemented('Subclasses of Function1D should overwrite the ' - '__call__ and to_hdf5 methods') + pass @classmethod def from_hdf5(cls, dataset):