Package ca.nengo.util

Examples of ca.nengo.util.ScriptGenException


          transformString.append(getTransformScript(dTermination, "transform = ".length() + 1));
        }
      }
      else
      {
        throw new ScriptGenException("Trying to generate script of non decoded termination which is not supported.");
      }

      transformString.append("]\n");
    
      // Now handle origin function if there is one
     
      String functionName = "";
      if(tempOrigin instanceof BasicOrigin && tempOrigin.getNode() instanceof FunctionInput)
      {
        originNodeFullName.append(tempOrigin.getNode().getName());
      }
      else
      {
        DecodedOrigin dOrigin;
        if(tempOrigin instanceof DecodedOrigin)
        {
          dOrigin = (DecodedOrigin) tempOrigin;
          originNodeFullName.append(tempOrigin.getNode().getName());
        }
        else if(tempOrigin instanceof NetworkArrayImpl.ArrayOrigin &&
            tempOrigin.getNode() instanceof NetworkArrayImpl)
        {
          originNodeFullName.deleteCharAt(originNodeFullName.length()-1);
          Node node = tempOrigin.getNode().getChildren()[0];
         
          try{
            dOrigin = (DecodedOrigin) node.getOrigin(tempOrigin.getName());
          }catch(StructuralException e){
            dOrigin = null;
          }
        }
        else
        {
          throw new ScriptGenException("Trying to generate script of non decoded origin which is not supported.");
        }
       
        functionName = addFunctionScript(py, dOrigin);
      }
     
View Full Code Here


        code = indentedCode.toString();
       
        if(code != ""){
          py.insert(0, code);
        }else{
          throw new ScriptGenException("Trying to generate script of non user-defined function on an origin which is not supported.");
        }
       
       
        return absFun.getName();
      }
     
      for(Function f: fns)
      {
        String exp;
        if(f instanceof PostfixFunction)
        {
          PostfixFunction pf = (PostfixFunction) f;
          exp = pf.getExpression();
         
          exp=exp.replaceAll("\\^","**");
          exp=exp.replaceAll("!"," not ");
          exp=exp.replaceAll("&"," and ");
          exp=exp.replaceAll("\\|"," or ");
          exp=exp.replaceAll("ln","log");
         
          for(int j = 0; j < f.getDimension(); j++)
          {
            String find = "x"+ Integer.toString(j);
            String replace = "x["+ Integer.toString(j) + "]";
            exp=exp.replaceAll(find, replace);
          }
        }
        else if(f instanceof IdentityFunction)
        {
          exp = "x[" + Integer.toString(((IdentityFunction) f).getIdentityDimension()) + "]";
        }
        else if(f instanceof ConstantFunction)
        {
          exp = Float.toString(((ConstantFunction) f).getValue());
        }
        else
        {
          throw new ScriptGenException("Trying to generate script of non user-defined function on an origin which is not supported.");
        }
       
        if (first)
        {
          funcString.append(exp);
View Full Code Here

        if (nodeFactory instanceof LIFNeuronFactory) {
            LIFNeuronFactory neuronFactory = (LIFNeuronFactory)nodeFactory;

            if (!(neuronFactory.getMaxRate() instanceof IndicatorPDF) ||
                !(neuronFactory.getIntercept() instanceof IndicatorPDF)) {
                throw new ScriptGenException("Max Rate or Intercept for LIF Neuron Factory not specified as a uniform range");
            }

            py.append(String.format(", tau_rc=%.3f, tau_ref=%.3f, max_rate=(%.1f, %.1f), intercept=(%.1f, %.1f)",
                        neuronFactory.getTauRC(),
                        neuronFactory.getTauRef(),
                        ((IndicatorPDF)neuronFactory.getMaxRate()).getLow(),
                        ((IndicatorPDF)neuronFactory.getMaxRate()).getHigh(),
                        ((IndicatorPDF)neuronFactory.getIntercept()).getLow(),
                        ((IndicatorPDF)neuronFactory.getIntercept()).getHigh()));
        } else {
            throw new ScriptGenException("Neuron Factory not supported. Only LIF Neuron Factory is supported");
        }

        py.append(String.format(", radius=%.2f)\n", myRadii[0]));
        return py.toString();
    }
View Full Code Here

           
            for (int i = 0; i < myFunctions.length; i++) {          
                FourierFunction func = (FourierFunction)myFunctions[i];
               
                if (func.getFundamental() == 0.0f) {
                    throw new ScriptGenException("Cannot generate a Fourier Function that was built by specifiying all frequencies, amplitudes and phases");
                }

                base.append(func.getFundamental());
                high.append(func.getCutoff());
                power.append(func.getRms());
View Full Code Here

TOP

Related Classes of ca.nengo.util.ScriptGenException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.