Changeset ce99754 in sasmodels


Ignore:
Timestamp:
Nov 2, 2017 5:44:10 PM (7 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
17db833
Parents:
6aee3ab
Message:

make sure that nominal values get into the weight vector even when there is no pd so that pd loops are simpler

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/details.py

    r6aee3ab rce99754  
    318318    parameter set in the vector. 
    319319    """ 
    320     value, dispersity, weight = zip(*mesh) 
     320    _, dispersity, weight = zip(*mesh) 
    321321    #weight = [w if len(w)>0 else [1.] for w in weight] 
    322322    weight = np.vstack([v.flatten() for v in meshgrid(*weight)]) 
  • sasmodels/product.py

    redb0f85 rce99754  
    279279    weight = values[nvalues + call_details.num_weights: nvalues + 2*call_details.num_weights] 
    280280    npars = model_info.parameters.npars 
    281     pairs = [(value[offset:offset+length], weight[offset:offset+length]) 
     281    # Note: changed from pairs ([v], [w]) to triples (p, [v], [w]), but the 
     282    # dispersion mesh code doesn't actually care about the nominal parameter 
     283    # value, p, so set it to None. 
     284    pairs = [(None, value[offset:offset+length], weight[offset:offset+length]) 
    282285             for p, offset, length 
    283286             in zip(model_info.parameters.call_parameters[2:2+npars], 
  • sasmodels/sasview_model.py

    ra06af5d rce99754  
    673673        #call_details.show() 
    674674        #print("pairs", pairs) 
     675        #for k, p in enumerate(self._model_info.parameters.call_parameters): 
     676        #    print(k, p.name, *pairs[k]) 
    675677        #print("params", self.params) 
    676678        #print("values", values) 
     
    678680        result = calculator(call_details, values, cutoff=self.cutoff, 
    679681                            magnetic=is_magnetic) 
     682        #print("result", result) 
    680683        self._intermediate_results = getattr(calculator, 'results', None) 
    681684        calculator.release() 
     
    761764                return self.multiplicity, [self.multiplicity], [1.0] 
    762765            else: 
    763                 # For hidden parameters use the default value. 
    764                 default = self._model_info.parameters.defaults.get(par.name, np.NaN) 
    765                 return default, [default], [1.0] 
     766                # For hidden parameters use NaN 
     767                return np.NaN, [np.NaN], [1.0] 
    766768        elif par.polydisperse: 
    767769            value = self.params[par.name] 
     
    776778        else: 
    777779            value = self.params[par.name] 
    778             return value, [value if par.relative_pd else 0.0], [1.0] 
     780            return value, [value], [1.0] 
    779781 
    780782def test_cylinder(): 
     
    797799    if np.isnan(value): 
    798800        raise ValueError("hardsphere returns null") 
     801 
     802def test_product(): 
     803    # type: () -> float 
     804    """ 
     805    Test that 2-D hardsphere model runs and doesn't produce NaN. 
     806    """ 
     807    S = _make_standard_model('hayter_msa')() 
     808    P = _make_standard_model('cylinder')() 
     809    model = MultiplicationModel(P, S) 
     810    value = model.evalDistribution([0.1, 0.1]) 
     811    if np.isnan(value): 
     812        raise ValueError("cylinder*hatyer_msa returns null") 
    799813 
    800814def test_rpa(): 
     
    850864if __name__ == "__main__": 
    851865    print("cylinder(0.1,0.1)=%g"%test_cylinder()) 
     866    #test_product() 
     867    #test_rpa() 
    852868    #test_empty_distribution() 
Note: See TracChangeset for help on using the changeset viewer.