Changeset 7ae2b7f in sasmodels


Ignore:
Timestamp:
Apr 11, 2016 10:48:41 AM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
fa5fd8d
Parents:
f619de7
Message:

still more linting; ignore numpy types

Location:
sasmodels
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/alignment.py

    r3c56da87 r7ae2b7f  
    1818to decide whether it is really required. 
    1919""" 
    20 import numpy as np 
     20import numpy as np  # type: ignore 
    2121 
    2222def align_empty(shape, dtype, alignment=128): 
  • sasmodels/bumps_model.py

    r6d6508e r7ae2b7f  
    1414import warnings 
    1515 
    16 import numpy as np 
     16import numpy as np  # type: ignore 
    1717 
    1818from .data import plot_theory 
     
    7979    # lazy import; this allows the doc builder and nosetests to run even 
    8080    # when bumps is not on the path. 
    81     from bumps.names import Parameter 
     81    from bumps.names import Parameter  # type: ignore 
    8282 
    8383    pars = {}     # floating point parameters 
  • sasmodels/compare.py

    r6d6508e r7ae2b7f  
    3434import traceback 
    3535 
    36 import numpy as np 
     36import numpy as np  # type: ignore 
    3737 
    3838from . import core 
     
    710710    try: 
    711711        model_info = core.load_model_info(name) 
    712     except ImportError, exc: 
     712    except ImportError as exc: 
    713713        print(str(exc)) 
    714714        print("Could not find model; use one of:\n    " + models) 
     
    860860    Explore the model using the Bumps GUI. 
    861861    """ 
    862     import wx 
    863     from bumps.names import FitProblem 
    864     from bumps.gui.app_frame import AppFrame 
     862    import wx  # type: ignore 
     863    from bumps.names import FitProblem  # type: ignore 
     864    from bumps.gui.app_frame import AppFrame  # type: ignore 
    865865 
    866866    problem = FitProblem(Explore(opts)) 
     
    883883    """ 
    884884    def __init__(self, opts): 
    885         from bumps.cli import config_matplotlib 
     885        from bumps.cli import config_matplotlib  # type: ignore 
    886886        from . import bumps_model 
    887887        config_matplotlib() 
  • sasmodels/compare_many.py

    r8bd7b77 r7ae2b7f  
    1717import traceback 
    1818 
    19 import numpy as np 
     19import numpy as np  # type: ignore 
    2020 
    2121from . import core 
  • sasmodels/convert.py

    r6d6508e r7ae2b7f  
    6262    # but only if we haven't already byteified it 
    6363    if isinstance(data, dict) and not ignore_dicts: 
    64         return { 
    65             _byteify(key, ignore_dicts=True): _byteify(value, ignore_dicts=True) 
    66             for key, value in data.iteritems() 
    67         } 
     64        return dict((_byteify(key, ignore_dicts=True), 
     65                     _byteify(value, ignore_dicts=True)) 
     66                    for key, value in data.items()) 
    6867    # if it's anything else, return it in its original form 
    6968    return data 
  • sasmodels/core.py

    rf619de7 r7ae2b7f  
    1212from glob import glob 
    1313 
    14 import numpy as np 
     14import numpy as np # type: ignore 
    1515 
    1616from . import generate 
  • sasmodels/custom/__init__.py

    rcd0a808 r7ae2b7f  
    1414try: 
    1515    # Python 3.5 and up 
    16     from importlib.util import spec_from_file_location, module_from_spec 
     16    from importlib.util import spec_from_file_location, module_from_spec  # type: ignore 
    1717    def load_module_from_path(fullname, path): 
    1818        spec = spec_from_file_location(fullname, path) 
  • sasmodels/data.py

    ree8f734 r7ae2b7f  
    3535import traceback 
    3636 
    37 import numpy as np 
     37import numpy as np  # type: ignore 
    3838 
    3939def load_data(filename): 
     
    4141    Load data using a sasview loader. 
    4242    """ 
    43     from sas.sascalc.dataloader.loader import Loader 
     43    from sas.sascalc.dataloader.loader import Loader  # type: ignore 
    4444    loader = Loader() 
    4545    data = loader.load(filename) 
     
    5353    Add a beam stop of the given *radius*.  If *outer*, make an annulus. 
    5454    """ 
    55     from sas.dataloader.manipulations import Ringcut 
     55    from sas.dataloader.manipulations import Ringcut  # type: ignore 
    5656    if hasattr(data, 'qx_data'): 
    5757        data.mask = Ringcut(0, radius)(data) 
     
    6868    Select half of the data, either "right" or "left". 
    6969    """ 
    70     from sas.dataloader.manipulations import Boxcut 
     70    from sas.dataloader.manipulations import Boxcut  # type: ignore 
    7171    if half == 'right': 
    7272        data.mask += \ 
     
    8181    Chop the top off the data, above *cutoff*. 
    8282    """ 
    83     from sas.dataloader.manipulations import Boxcut 
     83    from sas.dataloader.manipulations import Boxcut  # type: ignore 
    8484    data.mask += \ 
    8585        Boxcut(x_min=-np.inf, x_max=np.inf, y_min=-np.inf, y_max=cutoff)(data) 
     
    370370    Plot the data and residuals for 1D data. 
    371371    """ 
    372     import matplotlib.pyplot as plt 
    373     from numpy.ma import masked_array, masked 
     372    import matplotlib.pyplot as plt  # type: ignore 
     373    from numpy.ma import masked_array, masked  # type: ignore 
    374374 
    375375    use_data = use_data and data.y is not None 
     
    447447    Plot SESANS results. 
    448448    """ 
    449     import matplotlib.pyplot as plt 
     449    import matplotlib.pyplot as plt  # type: ignore 
    450450    use_data = use_data and data.y is not None 
    451451    use_theory = theory is not None 
     
    490490    Plot the data and residuals for 2D data. 
    491491    """ 
    492     import matplotlib.pyplot as plt 
     492    import matplotlib.pyplot as plt  # type: ignore 
    493493    use_data = use_data and data.data is not None 
    494494    use_theory = theory is not None 
     
    552552    *scale* can be 'log' for log scale data, or 'linear'. 
    553553    """ 
    554     import matplotlib.pyplot as plt 
    555     from numpy.ma import masked_array 
     554    import matplotlib.pyplot as plt  # type: ignore 
     555    from numpy.ma import masked_array  # type: ignore 
    556556 
    557557    image = np.zeros_like(data.qx_data) 
     
    593593    set_beam_stop(data, 0.004) 
    594594    plot_data(data) 
    595     import matplotlib.pyplot as plt; plt.show() 
     595    import matplotlib.pyplot as plt  # type: ignore 
     596    plt.show() 
    596597 
    597598 
  • sasmodels/details.py

    r4bfd277 r7ae2b7f  
    1 import numpy as np 
     1import numpy as np  # type: ignore 
     2 
     3try: 
     4    from typing import List 
     5except ImportError: 
     6    pass 
     7 
    28 
    39class CallDetails(object): 
     10    parts = None  # type: List["CallDetails"] 
    411    def __init__(self, model_info): 
    512        parameters = model_info.parameters 
  • sasmodels/direct_model.py

    r6d6508e r7ae2b7f  
    2323from __future__ import print_function 
    2424 
    25 import numpy as np 
    26  
    27 from . import sesans 
     25import numpy as np  # type: ignore 
     26 
     27# TODO: fix sesans module 
     28from . import sesans  # type: ignore 
    2829from . import weights 
    2930from . import resolution 
  • sasmodels/generate.py

    rf619de7 r7ae2b7f  
    160160import warnings 
    161161 
    162 import numpy as np 
     162import numpy as np  # type: ignore 
    163163 
    164164from .modelinfo import Parameter 
  • sasmodels/kernel.py

    rf619de7 r7ae2b7f  
    1414    from .details import CallDetails 
    1515    from .modelinfo import ModelInfo 
    16     import numpy as np 
     16    import numpy as np  # type: ignore 
    1717except ImportError: 
    1818    pass 
  • sasmodels/kernelcl.py

    rf619de7 r7ae2b7f  
    5252import warnings 
    5353 
    54 import numpy as np 
     54import numpy as np  # type: ignore 
    5555 
    5656try: 
    5757    raise NotImplementedError("OpenCL not yet implemented for new kernel template") 
    58     import pyopencl as cl 
     58    import pyopencl as cl  # type: ignore 
    5959    # Ask OpenCL for the default context so that we know that one exists 
    6060    cl.create_some_context(interactive=False) 
     
    6363    raise RuntimeError("OpenCL not available") 
    6464 
    65 from pyopencl import mem_flags as mf 
    66 from pyopencl.characterize import get_fast_inaccurate_build_options 
     65from pyopencl import mem_flags as mf  # type: ignore 
     66from pyopencl.characterize import get_fast_inaccurate_build_options  # type: ignore 
    6767 
    6868from . import generate 
  • sasmodels/kerneldll.py

    rf619de7 r7ae2b7f  
    4949import os 
    5050import tempfile 
    51 import ctypes as ct 
    52 from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float 
    53  
    54 import numpy as np 
     51import ctypes as ct  # type: ignore 
     52from ctypes import c_void_p, c_int32, c_longdouble, c_double, c_float  # type: ignore 
     53 
     54import numpy as np  # type: ignore 
    5555 
    5656from . import generate 
  • sasmodels/kernelpy.py

    rf619de7 r7ae2b7f  
    77:class:`kernelcl.GpuModel` and :class:`kerneldll.DllModel`. 
    88""" 
    9 import numpy as np 
    10 from numpy import pi, cos 
     9import numpy as np  # type: ignore 
     10from numpy import pi, cos  #type: ignore 
    1111 
    1212from . import details 
  • sasmodels/mixture.py

    rf619de7 r7ae2b7f  
    1212""" 
    1313from copy import copy 
    14 import numpy as np 
     14import numpy as np  # type: ignore 
    1515 
    1616from .modelinfo import Parameter, ParameterTable, ModelInfo 
  • sasmodels/model_test.py

    rf619de7 r7ae2b7f  
    5050import unittest 
    5151 
    52 import numpy as np 
     52import numpy as np  # type: ignore 
    5353 
    5454from .core import list_models, load_model_info, build_model, HAVE_OPENCL 
  • sasmodels/modelinfo.py

    rf619de7 r7ae2b7f  
    1010from os.path import abspath, basename, splitext 
    1111 
    12 import numpy as np 
     12import numpy as np  # type: ignore 
    1313 
    1414from .details import mono_details 
  • sasmodels/models/cylinder.py

    rf247314 r7ae2b7f  
    8282""" 
    8383 
    84 import numpy as np 
    85 from numpy import pi, inf 
     84import numpy as np  # type: ignore 
     85from numpy import pi, inf  # type: ignore 
    8686 
    8787name = "cylinder" 
  • sasmodels/product.py

    rf619de7 r7ae2b7f  
    1111*ProductModel(P, S)*. 
    1212""" 
    13 import numpy as np 
     13import numpy as np  # type: ignore 
    1414 
    1515from .details import dispersion_mesh 
     
    109109        effect_radius, vol_ratio = call_ER_VR(self.p_kernel.info, vol_pars) 
    110110 
    111         p_fixed[SCALE] = s_volfraction 
    112         p_fixed[BACKGROUND] = 0.0 
    113         s_fixed[SCALE] = scale 
    114         s_fixed[BACKGROUND] = 0.0 
    115         s_fixed[2] = s_volfraction/vol_ratio 
    116         s_pd[0] = [effect_radius], [1.0] 
    117  
    118         p_res = self.p_kernel(p_details, p_weights, p_values, cutoff) 
    119         s_res = self.s_kernel(s_details, s_weights, s_values, cutoff) 
     111        p_details, s_details = details.parts 
     112        p_res = self.p_kernel(p_details, weights, values, cutoff) 
     113        s_res = self.s_kernel(s_details, weights, values, cutoff) 
    120114        #print s_fixed, s_pd, p_fixed, p_pd 
    121115 
    122         return p_res*s_res + background 
     116        return values[0]*(p_res*s_res) + values[1] 
    123117 
    124118    def release(self): 
  • sasmodels/resolution.py

    r6d6508e r7ae2b7f  
    66from __future__ import division 
    77 
    8 from scipy.special import erf 
    9 from numpy import sqrt, log, log10 
    10 import numpy as np 
     8from scipy.special import erf  # type: ignore 
     9from numpy import sqrt, log, log10, exp, pi  # type: ignore 
     10import numpy as np  # type: ignore 
    1111 
    1212__all__ = ["Resolution", "Perfect1D", "Pinhole1D", "Slit1D", 
     
    3535    smeared theory I(q). 
    3636    """ 
    37     q = None 
    38     q_calc = None 
     37    q = None  # type: np.ndarray 
     38    q_calc = None  # type: np.ndarray 
    3939    def apply(self, theory): 
    4040        """ 
     
    489489    *q0* is the center, *dq* is the width and *q* are the points to evaluate. 
    490490    """ 
    491     from numpy import exp, pi 
    492491    return exp(-0.5*((q-q0)/dq)**2)/(sqrt(2*pi)*dq) 
    493492 
     
    500499    that make it slow to evaluate but give it good accuracy. 
    501500    """ 
    502     from scipy.integrate import romberg 
     501    from scipy.integrate import romberg  # type: ignore 
    503502 
    504503    par_set = set([p.name for p in form.info.parameters.call_parameters]) 
     
    555554    that make it slow to evaluate but give it good accuracy. 
    556555    """ 
    557     from scipy.integrate import romberg 
     556    from scipy.integrate import romberg  # type: ignore 
    558557 
    559558    par_set = set([p.name for p in form.info.parameters.call_parameters]) 
     
    752751        #tol = 0.001 
    753752        ## The default 3 sigma and no extra points gets 1% 
    754         q_calc, tol = None, 0.01 
     753        q_calc = None  # type: np.ndarray 
     754        tol = 0.01 
    755755        resolution = Pinhole1D(q, q_width, q_calc=q_calc) 
    756756        output = self._eval_sphere(pars, resolution) 
    757757        if 0: # debug plot 
    758             import matplotlib.pyplot as plt 
     758            import matplotlib.pyplot as plt  # type: ignore 
    759759            resolution = Perfect1D(q) 
    760760            source = self._eval_sphere(pars, resolution) 
     
    10281028    """ 
    10291029    import sys 
    1030     import xmlrunner 
     1030    import xmlrunner  # type: ignore 
    10311031 
    10321032    suite = unittest.TestSuite() 
     
    10761076        Iq_romb = romberg_pinhole_1d(resolution.q, dq, model, pars) 
    10771077 
    1078     import matplotlib.pyplot as plt 
     1078    import matplotlib.pyplot as plt  # type: ignore 
    10791079    plt.loglog(resolution.q_calc, theory, label='unsmeared') 
    10801080    plt.loglog(resolution.q, Iq, label='smeared', hold=True) 
     
    11111111    Run the resolution demos. 
    11121112    """ 
    1113     import matplotlib.pyplot as plt 
     1113    import matplotlib.pyplot as plt  # type: ignore 
    11141114    plt.subplot(121) 
    11151115    demo_pinhole_1d() 
  • sasmodels/resolution2d.py

    rd6f5da6 r7ae2b7f  
    77from __future__ import division 
    88 
    9 import numpy as np 
    10 from numpy import pi, cos, sin, sqrt 
     9import numpy as np  # type: ignore 
     10from numpy import pi, cos, sin, sqrt  # type: ignore 
    1111 
    1212from . import resolution 
  • sasmodels/sasview_model.py

    r0d99a6a r7ae2b7f  
    2121import logging 
    2222 
    23 import numpy as np 
     23import numpy as np  # type: ignore 
    2424 
    2525from . import core 
  • sasmodels/sesans.py

    r2684d45 r7ae2b7f  
    1212from __future__ import division 
    1313 
    14 import numpy as np 
    15 from numpy import pi, exp 
     14import numpy as np  # type: ignore 
     15from numpy import pi, exp  # type: ignore 
    1616from scipy.special import jv as besselj 
    1717#import direct_model.DataMixin as model 
  • sasmodels/weights.py

    r5c962df r7ae2b7f  
    33""" 
    44# TODO: include dispersion docs with the disperser models 
    5 from math import sqrt 
    6 import numpy as np 
    7 from scipy.special import gammaln 
     5from math import sqrt  # type: ignore 
     6import numpy as np  # type: ignore 
     7from scipy.special import gammaln  # type: ignore 
    88 
    99class Dispersion(object): 
Note: See TracChangeset for help on using the changeset viewer.