Example usage for java.lang Float isNaN

List of usage examples for java.lang Float isNaN

Introduction

In this page you can find the example usage for java.lang Float isNaN.

Prototype

public static boolean isNaN(float v) 

Source Link

Document

Returns true if the specified number is a Not-a-Number (NaN) value, false otherwise.

Usage

From source file:routines.system.BigDataParserUtils.java

public static Integer parseTo_Integer(float input) {
    if (Float.isNaN(input)) {
        return null;
    }/*w w  w  .j a v  a  2 s . co  m*/
    return ((Float) input).intValue();
}

From source file:net.demilich.metastone.bahaviour.ModifiedMCTS.MCTSCritique.java

@Override
public synchronized double getCritique(GameContext context, Player p) {
    java.util.logging.Logger.getLogger(caffe.class.getSimpleName()).setLevel(Level.OFF);
    ;/* ww  w  .j  ava 2  s  .c  om*/
    context = context.clone();
    p = context.getPlayer(p.getId());
    Caffe.set_mode(Caffe.CPU);
    //System.err.println("network is " + network + " " + context + " " + f);
    double input[] = f.getFeatures(true, context, p);
    if (input.length != 169) {
        System.err.println("heyyyoo");
        System.exit(0);
    }
    //System.err.println("input length is " + input.length);
    int hash = 0;
    for (int i = 0; i < input.length; i++) {
        hash += (i + 1) * (input[i] + i);
    }
    //System.err.println("hash is " + hash);
    String paramFile = "/home/dfreelan/dev/networks/singleLayerExample.prototxt";
    // System.err.println("HPASE IS: " + caffe_net.phase());
    java.util.logging.Logger.getGlobal().setLevel(Level.OFF);
    //caffe_net.ClearParamDiffs();

    FloatBlob dataBlob = caffe_net.blob_by_name("data");

    //dataBlob.Reshape(169, 1, 1, 1);
    dataBlob.set_cpu_data(toFloats(input));

    dataBlob.Update();
    dataBlob.Update();

    // System.err.println("bott blob length? "  + bottom.size());
    //FloatBlobVector top = caffe_net.ForwardPrefilled();
    caffe_net.ForwardFrom(1);
    float out = caffe_net.blob_by_name("tanhFinal").cpu_data().get();

    dataBlob.set_cpu_data(new float[169]);

    dataBlob.Update();
    dataBlob.Update();

    // System.err.println("bott blob length? "  + bottom.size());
    //FloatBlobVector top = caffe_net.ForwardPrefilled();
    caffe_net.ForwardFrom(1);
    float out2 = caffe_net.blob_by_name("tanhFinal").cpu_data().get();
    if (Float.isNaN(out) || out2 == out) {
        System.err.println("is nan you  or producing same output..." + out + " " + out2);
        out = 0;
        //f.printFeatures(context, p);
        // modelFile = "/home/dfreelan/dev/networks/_iter_350000.caffemodel";
        paramFile = "/home/dfreelan/dev/networks/singleLayerExample.prototxt";
        Caffe.set_mode(Caffe.CPU);

        try {
            //String str = FileUtils.readFileToString(new File(paramFile), "utf-8");
            ///System.err.println(str);
            if (modelFile != null) {
                caffe_net = new FloatNet(paramFile, TEST);
                caffe_net.CopyTrainedLayersFrom(modelFile);
            }

        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
        return getCritique(context, p);
    }

    //System.err.println(" i made a deicsion! "  + out);
    return (out + 1.0) / 2.0;
    //NeuralDataSet sample = new BasicNeuralDataSet(new double[][] 
    //{ f.getFeatures(true, context, context.getPlayer(playerID)) }); 

}

From source file:eu.itesla_project.eurostag.EurostagImpactAnalysis.java

private static void writeLimits(Network network, EurostagDictionary dictionary, Domain domain, OutputStream os)
        throws IOException {
    GenericArchive archive = domain.getArchiveFactory().create(GenericArchive.class);
    try (FileSystem fileSystem = ShrinkWrapFileSystems.newFileSystem(archive)) {
        Path rootDir = fileSystem.getPath("/");
        // dump first current limits for each of the branches
        try (BufferedWriter writer = Files.newBufferedWriter(rootDir.resolve(CURRENT_LIMITS_CSV),
                StandardCharsets.UTF_8)) {
            for (Line l : network.getLines()) {
                dumpLimits(dictionary, writer, l);
            }//  w ww. ja v a 2s .  c o m
            for (TwoWindingsTransformer twt : network.getTwoWindingsTransformers()) {
                dumpLimits(dictionary, writer, twt);
            }
            for (DanglingLine dl : network.getDanglingLines()) {
                dumpLimits(dictionary, writer, dl.getId(), dl.getCurrentLimits(), null,
                        dl.getTerminal().getVoltageLevel().getNominalV(),
                        dl.getTerminal().getVoltageLevel().getNominalV());
            }
        }
        try (BufferedWriter writer = Files.newBufferedWriter(rootDir.resolve(VOLTAGE_LIMITS_CSV),
                StandardCharsets.UTF_8)) {
            for (Bus b : network.getBusBreakerView().getBuses()) {
                VoltageLevel vl = b.getVoltageLevel();
                if (!Float.isNaN(vl.getLowVoltageLimit()) && !Float.isNaN(vl.getHighVoltageLimit())) {
                    writer.write(dictionary.getEsgId(b.getId()));
                    writer.write(";");
                    writer.write(Float.toString(vl.getLowVoltageLimit()));
                    writer.write(";");
                    writer.write(Float.toString(vl.getHighVoltageLimit()));
                    writer.write(";");
                    writer.write(Float.toString(vl.getNominalV()));
                    writer.newLine();
                }
            }
        }

        //dump lines dictionary, for WP43 integration
        dumpLinesDictionary(network, dictionary, rootDir);
        //dump buses dictionary, for WP43 integration
        dumpBusesDictionary(network, dictionary, rootDir);
    }

    archive.as(ZipExporter.class).exportTo(os);
}

From source file:at.pagu.soldockr.core.query.Criteria.java

protected String createQueryFragmentForCriteria(Criteria chainedCriteria) {
    StringBuilder queryFragment = new StringBuilder();
    Iterator<CriteriaEntry> it = chainedCriteria.criteria.iterator();
    boolean singeEntryCriteria = (chainedCriteria.criteria.size() == 1);
    if (chainedCriteria.field != null) {
        queryFragment.append(chainedCriteria.field.getName());
        queryFragment.append(DELIMINATOR);
        if (!singeEntryCriteria) {
            queryFragment.append("(");
        }//from www  .  ja  v  a 2  s .  c  om
        while (it.hasNext()) {
            CriteriaEntry entry = it.next();
            queryFragment.append(processCriteriaEntry(entry.getKey(), entry.getValue()));
            if (it.hasNext()) {
                queryFragment.append(CRITERIA_VALUE_SEPERATOR);
            }
        }
        if (!singeEntryCriteria) {
            queryFragment.append(")");
        }
        if (!Float.isNaN(chainedCriteria.boost)) {
            queryFragment.append("^" + chainedCriteria.boost);
        }
    } else {
        return chainedCriteria.getQueryString();
    }
    return queryFragment.toString();
}

From source file:nl.hnogames.domoticz.Fragments.Graph.java

@SuppressWarnings("SpellCheckingInspection")
private LineData generateData(View view) {
    try {/*  w  w  w .  j  av  a2  s.  c  o  m*/
        List<LineDataSet> entries = new ArrayList<LineDataSet>();

        List<Entry> valuest = new ArrayList<>();
        List<Entry> valuestMin = new ArrayList<>();
        List<Entry> valuestMax = new ArrayList<>();

        List<Entry> valuesse = new ArrayList<>();
        List<Entry> valueshu = new ArrayList<>();
        List<Entry> valuesba = new ArrayList<>();
        List<Entry> valuesc = new ArrayList<>();

        List<Entry> valuesv = new ArrayList<>();
        List<Entry> valuesv2 = new ArrayList<>();
        List<Entry> valuesvMin = new ArrayList<>();
        List<Entry> valuesvMax = new ArrayList<>();

        List<Entry> valuessp = new ArrayList<>();
        List<Entry> valuesdi = new ArrayList<>();
        List<Entry> valuesuv = new ArrayList<>();
        List<Entry> valuesu = new ArrayList<>();
        List<Entry> valuesmm = new ArrayList<>();

        List<Entry> valuesco2 = new ArrayList<>();
        List<Entry> valuesco2min = new ArrayList<>();
        List<Entry> valuesco2max = new ArrayList<>();

        ArrayList<String> axisValueX = new ArrayList<>();

        int counter = 0;
        boolean addHumidity = false;
        boolean addBarometer = false;
        boolean addTemperature = false;
        boolean addTemperatureRange = false;
        boolean addSetpoint = false;
        boolean addCounter = false;
        boolean addPercentage = false;
        boolean addSecondPercentage = false;
        boolean addPercentageRange = false;
        boolean addSunPower = false;
        boolean addDirection = false;
        boolean addSpeed = false;
        boolean addRain = false;
        boolean addCO2 = false;
        boolean addCO2Min = false;
        boolean addCO2Max = false;
        boolean addUsage = false;
        Calendar mydate = Calendar.getInstance();

        int stepcounter = 0;
        for (GraphPointInfo g : this.mGraphList) {
            stepcounter++;
            if (stepcounter == this.steps) {
                stepcounter = 0;

                try {
                    try {
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
                        mydate.setTime(sdf.parse(g.getDateTime()));
                    } catch (ParseException e) {
                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                        mydate.setTime(sdf.parse(g.getDateTime()));
                    }

                    if (!Float.isNaN(g.getTemperature())) {
                        addTemperature = true;
                        valuest.add(new Entry(mydate.getTimeInMillis(), g.getTemperature()));

                        if (g.hasTemperatureRange()) {
                            addTemperatureRange = true;
                            valuestMax.add(new Entry(mydate.getTimeInMillis(), g.getTemperatureMax()));
                            valuestMin.add(new Entry(mydate.getTimeInMillis(), g.getTemperatureMin()));
                        }
                    }

                    if (!Float.isNaN(g.getSetPoint())) {
                        addSetpoint = true;
                        valuesse.add(new Entry(mydate.getTimeInMillis(), g.getSetPoint()));
                    }

                    if (g.getBarometer() != null && g.getBarometer().length() > 0) {
                        addBarometer = true;
                        try {
                            valuesba.add(
                                    new Entry(mydate.getTimeInMillis(), Integer.parseInt(g.getBarometer())));
                        } catch (Exception ex) {
                            valuesba.add(
                                    new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getBarometer())));
                        }
                    }

                    if (g.getHumidity() != null && g.getHumidity().length() > 0) {
                        addHumidity = true;
                        try {
                            valueshu.add(
                                    new Entry(mydate.getTimeInMillis(), Integer.parseInt(g.getHumidity())));
                        } catch (Exception ex) {
                            valuesba.add(
                                    new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getHumidity())));
                        }
                    }

                    if (g.getValue() != null && g.getValue().length() > 0) {
                        addPercentage = true;
                        valuesv.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getValue())));
                        if (g.hasValueRange()) {
                            addPercentageRange = true;
                            valuesvMin.add(
                                    new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getValueMin())));
                            valuesvMax.add(
                                    new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getValueMax())));
                        }
                    }

                    if (g.getSecondValue() != null && g.getSecondValue().length() > 0) {
                        addSecondPercentage = true;
                        valuesv2.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getSecondValue())));
                    }

                    if (g.getCounter() != null && g.getCounter().length() > 0) {
                        addCounter = true;
                        valuesc.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getCounter())));
                    }

                    if (g.getSpeed() != null && g.getSpeed().length() > 0) {
                        addSpeed = true;
                        valuessp.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getSpeed())));
                    }

                    if (g.getDirection() != null && g.getDirection().length() > 0) {
                        addDirection = true;
                        valuesdi.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getDirection())));
                    }

                    if (g.getSunPower() != null && g.getSunPower().length() > 0) {
                        addSunPower = true;
                        valuesuv.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getSunPower())));
                    }

                    if (g.getUsage() != null && g.getUsage().length() > 0) {
                        addUsage = true;
                        valuesu.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getUsage())));
                    }

                    if (g.getRain() != null && g.getRain().length() > 0) {
                        addRain = true;
                        valuesmm.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getRain())));
                    }

                    if (g.getCo2() != null && g.getCo2().length() > 0) {
                        addCO2 = true;
                        valuesco2.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getCo2())));
                    }

                    if (g.getCo2Min() != null && g.getCo2Min().length() > 0) {
                        addCO2Min = true;
                        valuesco2min.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getCo2Min())));
                    }

                    if (g.getCo2Max() != null && g.getCo2Max().length() > 0) {
                        addCO2Max = true;
                        valuesco2max.add(new Entry(mydate.getTimeInMillis(), Float.parseFloat(g.getCo2Max())));
                    }

                    counter++;
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }

        if ((addTemperature && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_temperature)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuest,
                    ((TextView) view.findViewById(R.id.legend_temperature)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_blue_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);

            if ((addSetpoint && !enableFilters) || (filterLabels != null && filterLabels
                    .contains(((TextView) view.findViewById(R.id.legend_set_point)).getText().toString()))) {
                dataSet = new LineDataSet(valuesse,
                        ((TextView) view.findViewById(R.id.legend_set_point)).getText().toString()); // add entries to dataset
                dataSet.setColor(ContextCompat.getColor(context, R.color.material_pink_600));
                dataSet.setDrawCircles(false);
                dataSet.setMode(LineDataSet.Mode.LINEAR);
                entries.add(dataSet);
            }

            if (addTemperatureRange) {
                dataSet = new LineDataSet(valuestMax, "Max"); // add entries to dataset
                dataSet.setColor(ContextCompat.getColor(context, R.color.md_blue_50));
                dataSet.setDrawCircles(false);
                dataSet.setMode(LineDataSet.Mode.LINEAR);
                dataSet.setDrawFilled(true);
                dataSet.setFillColor(R.color.md_blue_300);
                entries.add(dataSet);

                dataSet = new LineDataSet(valuestMin, "Min"); // add entries to dataset
                dataSet.setColor(ContextCompat.getColor(context, R.color.md_blue_50));
                dataSet.setDrawCircles(false);
                dataSet.setMode(LineDataSet.Mode.LINEAR);
                dataSet.setFillAlpha(255);
                dataSet.setFillColor(R.color.white);
                dataSet.setDrawFilled(true);
                entries.add(dataSet);
            }
        }

        if ((addHumidity && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_humidity)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valueshu,
                    ((TextView) view.findViewById(R.id.legend_humidity)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_orange_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addBarometer && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_barometer)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesba,
                    ((TextView) view.findViewById(R.id.legend_barometer)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_green_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addCounter && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_counter)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesc,
                    ((TextView) view.findViewById(R.id.legend_counter)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_indigo_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addPercentage && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_percentage)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesv,
                    ((TextView) view.findViewById(R.id.legend_percentage)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_yellow_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);

            if (addPercentageRange) {
                dataSet = new LineDataSet(valuesvMax, "Max"); // add entries to dataset
                dataSet.setColor(ContextCompat.getColor(context, R.color.md_blue_50));
                dataSet.setDrawCircles(false);
                dataSet.setMode(LineDataSet.Mode.LINEAR);
                dataSet.setDrawFilled(true);
                dataSet.setFillColor(R.color.md_blue_300);
                entries.add(dataSet);

                dataSet = new LineDataSet(valuesvMin, "Min"); // add entries to dataset
                dataSet.setColor(ContextCompat.getColor(context, R.color.md_blue_50));
                dataSet.setDrawCircles(false);
                dataSet.setMode(LineDataSet.Mode.LINEAR);
                dataSet.setFillAlpha(255);
                dataSet.setFillColor(R.color.white);
                dataSet.setDrawFilled(true);
                entries.add(dataSet);
            }
        }

        if ((addSecondPercentage && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_percentage2)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesv2,
                    ((TextView) view.findViewById(R.id.legend_percentage2)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_orange_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addDirection && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_direction)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesdi,
                    ((TextView) view.findViewById(R.id.legend_direction)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_green_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addSunPower && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_sunpower)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesuv,
                    ((TextView) view.findViewById(R.id.legend_sunpower)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_deep_purple_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addSpeed && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_speed)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuessp,
                    ((TextView) view.findViewById(R.id.legend_speed)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_amber_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addUsage && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_usage)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesu,
                    ((TextView) view.findViewById(R.id.legend_usage)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_orange_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addRain && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_rain)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesmm,
                    ((TextView) view.findViewById(R.id.legend_rain)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_light_green_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addCO2 && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_co2)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesco2,
                    ((TextView) view.findViewById(R.id.legend_co2)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_blue_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addCO2Min && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_co2min)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesco2min,
                    ((TextView) view.findViewById(R.id.legend_co2min)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.material_light_green_600));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if ((addCO2Max && !enableFilters) || (filterLabels != null && filterLabels
                .contains(((TextView) view.findViewById(R.id.legend_co2max)).getText().toString()))) {
            LineDataSet dataSet = new LineDataSet(valuesco2max,
                    ((TextView) view.findViewById(R.id.legend_co2max)).getText().toString()); // add entries to dataset
            dataSet.setColor(ContextCompat.getColor(context, R.color.md_red_400));
            dataSet.setDrawCircles(false);
            dataSet.setMode(LineDataSet.Mode.LINEAR);
            entries.add(dataSet);
        }

        if (entries.size() > 1) {
            if (addTemperature) {
                (view.findViewById(R.id.legend_temperature)).setVisibility(View.VISIBLE);
                if (addSetpoint) {
                    (view.findViewById(R.id.legend_set_point)).setVisibility(View.VISIBLE);
                }
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_temperature)).getText());

            }

            if (addHumidity) {
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_humidity)).getText());
                (view.findViewById(R.id.legend_humidity)).setVisibility(View.VISIBLE);
            }

            if (addBarometer) {
                (view.findViewById(R.id.legend_barometer)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_barometer)).getText());
            }

            if (addCounter) {
                (view.findViewById(R.id.legend_counter)).setVisibility(View.VISIBLE);
                ((TextView) view.findViewById(R.id.legend_counter)).setText(axisYLabel);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_counter)).getText());
            }

            if (addPercentage) {
                (view.findViewById(R.id.legend_percentage)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_percentage)).getText());
            }

            if (addSecondPercentage) {
                (view.findViewById(R.id.legend_percentage2)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_percentage2)).getText());
            }

            if (addDirection) {
                (view.findViewById(R.id.legend_direction)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_direction)).getText());
            }

            if (addSunPower) {
                (view.findViewById(R.id.legend_sunpower)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_sunpower)).getText());
            }

            if (addSpeed) {
                (view.findViewById(R.id.legend_speed)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_speed)).getText());
            }

            if (addUsage) {
                (view.findViewById(R.id.legend_usage)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_usage)).getText());
            }

            if (addRain) {
                (view.findViewById(R.id.legend_rain)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_rain)).getText());
            }

            if (addCO2) {
                (view.findViewById(R.id.legend_co2)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_co2)).getText());
            }

            if (addCO2Min) {
                (view.findViewById(R.id.legend_co2min)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_co2min)).getText());
            }

            if (addCO2Max) {
                (view.findViewById(R.id.legend_co2max)).setVisibility(View.VISIBLE);
                addLabelFilters((String) ((TextView) view.findViewById(R.id.legend_co2max)).getText());
            }
        }

        ArrayList<ILineDataSet> dataSets = new ArrayList<ILineDataSet>();
        for (LineDataSet s : entries)
            dataSets.add(s);

        LineData lineChartData = new LineData(dataSets);
        lineChartData.setHighlightEnabled(true);
        lineChartData.setDrawValues(false);

        return lineChartData;
    } catch (Exception ex) {
        return null;
    }
}

From source file:org.apache.vxquery.runtime.functions.cast.CastToStringOperation.java

@Override
public void convertFloat(FloatPointable floatp, DataOutput dOut) throws SystemException, IOException {
    abvsInner.reset();/*from w ww. j a va 2 s . c o m*/
    float value = floatp.getFloat();

    if (!Float.isInfinite(value) && !Float.isNaN(value) && Math.abs(value) >= 0.000001
            && Math.abs(value) <= 1000000) {
        CastToDecimalOperation castToDecimal = new CastToDecimalOperation();
        castToDecimal.convertFloat(floatp, dOutInner);
        XSDecimalPointable decp = (XSDecimalPointable) XSDecimalPointable.FACTORY.createPointable();
        decp.set(abvsInner.getByteArray(), abvsInner.getStartOffset() + 1, abvsInner.getLength());
        convertDecimal(decp, dOut);
    } else if (value == -0.0f || value == 0.0f) {
        long bits = Float.floatToIntBits(value);
        boolean negative = ((bits >> 31) == 0) ? false : true;

        if (negative) {
            FunctionHelper.writeChar('-', dOutInner);
        }
        FunctionHelper.writeCharSequence("0", dOutInner);
        sendStringDataOutput(dOut);
    } else {
        convertFloatCanonical(floatp, dOut);
    }
}

From source file:org.alfresco.repo.jscript.app.JSONConversionComponent.java

/**
 * Handles the work of converting values to JSON.
 * /*from  w  w  w .  j a va2 s .co m*/
 * @param nodeRef NodeRef
 * @param propertyName QName
 * @param key String
 * @param value Serializable
 * @return the JSON value
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Object propertyToJSON(final NodeRef nodeRef, final QName propertyName, final String key,
        final Serializable value) {
    if (value != null) {
        // Has a decorator has been registered for this property?
        if (propertyDecorators.containsKey(propertyName)) {
            JSONAware jsonAware = propertyDecorators.get(propertyName).decorate(propertyName, nodeRef, value);
            if (jsonAware != null) {
                return jsonAware;
            }
        } else {
            // Built-in data type processing
            if (value instanceof Date) {
                JSONObject dateObj = new JSONObject();
                dateObj.put("value", JSONObject.escape(value.toString()));
                dateObj.put("iso8601", JSONObject.escape(ISO8601DateFormat.format((Date) value)));
                return dateObj;
            } else if (value instanceof List) {
                // Convert the List to a JSON list by recursively calling propertyToJSON
                List<Object> jsonList = new ArrayList<Object>(((List<Serializable>) value).size());
                for (Serializable listItem : (List<Serializable>) value) {
                    jsonList.add(propertyToJSON(nodeRef, propertyName, key, listItem));
                }
                return jsonList;
            } else if (value instanceof Double) {
                return (Double.isInfinite((Double) value) || Double.isNaN((Double) value) ? null
                        : value.toString());
            } else if (value instanceof Float) {
                return (Float.isInfinite((Float) value) || Float.isNaN((Float) value) ? null
                        : value.toString());
            } else {
                return value.toString();
            }
        }
    }
    return null;
}

From source file:org.caleydo.view.bicluster.elem.band.BandElement.java

private boolean isValidBand() {
    return band != null && band.size() > 0 && !Float.isNaN(band.getCurveTop().get(0).x());
}

From source file:nl.uva.illc.dataselection.InvitationModel.java

public static void training() throws FileNotFoundException, InterruptedException {

    log.info("Starting Invitation EM ...");

    latch = new CountDownLatch(2);
    ttable[2] = new TranslationTable();
    ttable[3] = new TranslationTable();
    initializeTranslationTable(src_outdomain, trg_outdomain, ttable[2]);
    initializeTranslationTable(trg_outdomain, src_outdomain, ttable[3]);
    latch.await();/*  ww  w.j ava2s  .com*/

    for (int i = 1; i <= iMAX; i++) {
        log.info("Iteration " + i);
        HashIntObjMap<Result> results = HashIntObjMaps.newMutableMap();

        float sPD[][] = new float[2][src_mixdomain.length];

        int splits = 10;
        int split_size = src_mixdomain.length / splits;

        latch = new CountDownLatch(splits);
        for (int s = 0; s < splits; s++) {
            int start = s * split_size;
            int end = start + split_size;
            if (s == (splits - 1)) {
                end = src_mixdomain.length;
            }
            calcualteScore(start, end, sPD);
        }
        latch.await();

        float countPD[] = new float[2];
        countPD[0] = Float.NEGATIVE_INFINITY;
        countPD[1] = Float.NEGATIVE_INFINITY;

        for (int sent = 0; sent < src_mixdomain.length; sent++) {

            if (ignore.containsKey(sent))
                continue;

            if (Float.isNaN(sPD[0][sent]) || Float.isNaN(sPD[1][sent])) {
                ignore.put(sent, sent);
                log.info("Ignoring " + (sent + 1));
                continue;
            }

            countPD[0] = logAdd(countPD[0], sPD[0][sent]);
            countPD[1] = logAdd(countPD[1], sPD[1][sent]);

            float srcP = lm[0][sent];
            float trgP = lm[1][sent];
            results.put(sent, new Result(sent, sPD[1][sent], srcP + trgP));

        }

        float newPD1 = countPD[1] - logAdd(countPD[0], countPD[1]);
        float newPD0 = countPD[0] - logAdd(countPD[0], countPD[1]);

        log.info("PD1 ~ PD0 " + Math.exp(newPD1) + " ~ " + Math.exp(newPD0));

        writeResult(i, results);

        if (i > 1 && Math.abs(Math.exp(newPD1) - Math.exp(PD1)) <= CONV_THRESHOLD) {
            log.info("Convergence threshold reached.");
            break;
        }

        PD1 = newPD1;
        PD0 = newPD0;

        if (i < iMAX) {

            latch = new CountDownLatch(4);
            updateTranslationTable(src_mixdomain, trg_mixdomain, ttable[0], sPD[1]);
            updateTranslationTable(trg_mixdomain, src_mixdomain, ttable[1], sPD[1]);
            updateTranslationTable(src_mixdomain, trg_mixdomain, ttable[2], sPD[0]);
            updateTranslationTable(trg_mixdomain, src_mixdomain, ttable[3], sPD[0]);
            latch.await();
        }

    }
}

From source file:routines.system.BigDataParserUtils.java

public static int parseTo_int(float input) {
    if (Float.isNaN(input)) {
        return defaultValueInt;
    }/*from  ww  w . j a  v a 2 s.  co m*/
    return ((Float) input).intValue();
}