Search in sources :

Example 51 with EnumMap

use of java.util.EnumMap in project ART-TIME by Artezio.

the class SettingsBeanTest method testGetSettings_ifNotNull.

@Test
public void testGetSettings_ifNotNull() throws Exception {
    settings = new Settings(new EnumMap<>(Setting.Name.class));
    setField(settingsBean, "settings", settings);
    Settings actual = settingsBean.getSettings();
    assertSame(settings, actual);
}
Also used : Setting(com.artezio.arttime.config.Setting) EnumMap(java.util.EnumMap) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test)

Example 52 with EnumMap

use of java.util.EnumMap in project ART-TIME by Artezio.

the class SchedulerTest method testActualizeSettings_timeoutHasChanged.

@Test
public void testActualizeSettings_timeoutHasChanged() throws NoSuchFieldException {
    scheduler = createMockBuilder(Scheduler.class).addMockedMethod("createIntervalTimer").createMock();
    settings = new Settings(new EnumMap<>(Setting.Name.class));
    settings.setTimerHoursInterval(200);
    settings.setTimerMinutesInterval(500);
    Settings newSettings = new Settings(new EnumMap<>(Setting.Name.class));
    newSettings.setTimerHoursInterval(777);
    newSettings.setTimerMinutesInterval(333);
    setField(scheduler, "settings", settings);
    setField(scheduler, "settingsService", settingsService);
    expect(settingsService.getSettings()).andReturn(newSettings);
    scheduler.createIntervalTimer();
    expectLastCall().once();
    replay(settingsService, scheduler);
    scheduler.actualizeSettings();
    verify(settingsService, scheduler);
}
Also used : Setting(com.artezio.arttime.config.Setting) EnumMap(java.util.EnumMap) Settings(com.artezio.arttime.config.Settings) Test(org.junit.Test)

Example 53 with EnumMap

use of java.util.EnumMap in project gatk by broadinstitute.

the class ReadRecalibrationInfoUnitTest method testReadInfo.

@Test(dataProvider = "InfoProvider")
public void testReadInfo(final int readLength, final boolean includeIndelErrors) {
    final ReadCovariates covariates = new ReadCovariates(readLength, 2, new CovariateKeyCache());
    final byte[] bases = new byte[readLength];
    final byte[] baseQuals = new byte[readLength];
    final byte[] insertionQuals = new byte[readLength];
    final byte[] deletionQuals = new byte[readLength];
    final boolean[] skips = new boolean[readLength];
    final double[] snpErrors = new double[readLength];
    final double[] insertionErrors = new double[readLength];
    final double[] deletionsErrors = new double[readLength];
    for (int i = 0; i < readLength; i++) {
        bases[i] = 'A';
        baseQuals[i] = (byte) (i % SAMUtils.MAX_PHRED_SCORE);
        insertionQuals[i] = (byte) ((i + 1) % SAMUtils.MAX_PHRED_SCORE);
        deletionQuals[i] = (byte) ((i + 2) % SAMUtils.MAX_PHRED_SCORE);
        skips[i] = i % 2 == 0;
        snpErrors[i] = 1.0 / (i + 1);
        insertionErrors[i] = 0.5 / (i + 1);
        deletionsErrors[i] = 0.3 / (i + 1);
    }
    final EnumMap<EventType, double[]> errors = new EnumMap<>(EventType.class);
    errors.put(EventType.BASE_SUBSTITUTION, snpErrors);
    errors.put(EventType.BASE_INSERTION, insertionErrors);
    errors.put(EventType.BASE_DELETION, deletionsErrors);
    final EnumMap<EventType, byte[]> quals = new EnumMap<>(EventType.class);
    quals.put(EventType.BASE_SUBSTITUTION, baseQuals);
    quals.put(EventType.BASE_INSERTION, insertionQuals);
    quals.put(EventType.BASE_DELETION, deletionQuals);
    final GATKRead read = ArtificialReadUtils.createArtificialRead(bases, baseQuals, readLength + "M");
    if (includeIndelErrors) {
        ReadUtils.setInsertionBaseQualities(read, insertionQuals);
        ReadUtils.setDeletionBaseQualities(read, deletionQuals);
    }
    final ReadRecalibrationInfo info = new ReadRecalibrationInfo(read, covariates, skips, snpErrors, insertionErrors, deletionsErrors);
    Assert.assertEquals(info.getCovariatesValues(), covariates);
    Assert.assertEquals(info.getRead(), read);
    for (int i = 0; i < readLength; i++) {
        Assert.assertEquals(info.skip(i), skips[i]);
        for (final EventType et : EventType.values()) {
            Assert.assertEquals(info.getErrorFraction(et, i), errors.get(et)[i]);
            final byte expectedQual = et == EventType.BASE_SUBSTITUTION || includeIndelErrors ? quals.get(et)[i] : ReadUtils.DEFAULT_INSERTION_DELETION_QUAL;
            Assert.assertEquals(info.getQual(et, i), expectedQual);
        }
    }
}
Also used : GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) CovariateKeyCache(org.broadinstitute.hellbender.utils.recalibration.covariates.CovariateKeyCache) ReadCovariates(org.broadinstitute.hellbender.utils.recalibration.covariates.ReadCovariates) EnumMap(java.util.EnumMap) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 54 with EnumMap

use of java.util.EnumMap in project android by JetBrains.

the class StateChartVisualTest method getFruitStateColor.

private static EnumMap<MockFruitState, Color> getFruitStateColor() {
    EnumMap<MockFruitState, Color> colors = new EnumMap<>(MockFruitState.class);
    colors.put(MockFruitState.NONE, new JBColor(new Color(0, 0, 0, 0), new Color(0, 0, 0, 0)));
    colors.put(MockFruitState.APPLE, JBColor.RED);
    colors.put(MockFruitState.GRAPE, JBColor.MAGENTA);
    colors.put(MockFruitState.ORANGE, JBColor.ORANGE);
    colors.put(MockFruitState.BANANA, JBColor.YELLOW);
    return colors;
}
Also used : JBColor(com.intellij.ui.JBColor) JBColor(com.intellij.ui.JBColor) EnumMap(java.util.EnumMap)

Example 55 with EnumMap

use of java.util.EnumMap in project weex-example by KalicyZhou.

the class OneDReader method doDecode.

/**
   * We're going to examine rows from the middle outward, searching alternately above and below the
   * middle, and farther out each time. rowStep is the number of rows between each successive
   * attempt above and below the middle. So we'd scan row middle, then middle - rowStep, then
   * middle + rowStep, then middle - (2 * rowStep), etc.
   * rowStep is bigger as the image is taller, but is always at least 1. We've somewhat arbitrarily
   * decided that moving up and down by about 1/16 of the image is pretty good; we try more of the
   * image if "trying harder".
   *
   * @param image The image to decode
   * @param hints Any hints that were requested
   * @return The contents of the decoded barcode
   * @throws NotFoundException Any spontaneous errors which occur
   */
private Result doDecode(BinaryBitmap image, Map<DecodeHintType, ?> hints) throws NotFoundException {
    int width = image.getWidth();
    int height = image.getHeight();
    BitArray row = new BitArray(width);
    int middle = height >> 1;
    boolean tryHarder = hints != null && hints.containsKey(DecodeHintType.TRY_HARDER);
    int rowStep = Math.max(1, height >> (tryHarder ? 8 : 5));
    int maxLines;
    if (tryHarder) {
        // Look at the whole image, not just the center
        maxLines = height;
    } else {
        // 15 rows spaced 1/32 apart is roughly the middle half of the image
        maxLines = 15;
    }
    for (int x = 0; x < maxLines; x++) {
        // Scanning from the middle out. Determine which row we're looking at next:
        int rowStepsAboveOrBelow = (x + 1) / 2;
        // i.e. is x even?
        boolean isAbove = (x & 0x01) == 0;
        int rowNumber = middle + rowStep * (isAbove ? rowStepsAboveOrBelow : -rowStepsAboveOrBelow);
        if (rowNumber < 0 || rowNumber >= height) {
            // Oops, if we run off the top or bottom, stop
            break;
        }
        // Estimate black point for this row and load it:
        try {
            row = image.getBlackRow(rowNumber, row);
        } catch (NotFoundException ignored) {
            continue;
        }
        // handle decoding upside down barcodes.
        for (int attempt = 0; attempt < 2; attempt++) {
            if (attempt == 1) {
                // trying again?
                // reverse the row and continue
                row.reverse();
                // that start on the center line.
                if (hints != null && hints.containsKey(DecodeHintType.NEED_RESULT_POINT_CALLBACK)) {
                    Map<DecodeHintType, Object> newHints = new EnumMap<>(DecodeHintType.class);
                    newHints.putAll(hints);
                    newHints.remove(DecodeHintType.NEED_RESULT_POINT_CALLBACK);
                    hints = newHints;
                }
            }
            try {
                // Look for a barcode
                Result result = decodeRow(rowNumber, row, hints);
                // We found our barcode
                if (attempt == 1) {
                    // But it was upside down, so note that
                    result.putMetadata(ResultMetadataType.ORIENTATION, 180);
                    // And remember to flip the result points horizontally.
                    ResultPoint[] points = result.getResultPoints();
                    if (points != null) {
                        points[0] = new ResultPoint(width - points[0].getX() - 1, points[0].getY());
                        points[1] = new ResultPoint(width - points[1].getX() - 1, points[1].getY());
                    }
                }
                return result;
            } catch (ReaderException re) {
            // continue -- just couldn't decode this row
            }
        }
    }
    throw NotFoundException.getNotFoundInstance();
}
Also used : ResultPoint(com.google.zxing.ResultPoint) DecodeHintType(com.google.zxing.DecodeHintType) NotFoundException(com.google.zxing.NotFoundException) BitArray(com.google.zxing.common.BitArray) EnumMap(java.util.EnumMap) ResultPoint(com.google.zxing.ResultPoint) Result(com.google.zxing.Result) ReaderException(com.google.zxing.ReaderException)

Aggregations

EnumMap (java.util.EnumMap)389 Map (java.util.Map)73 ArrayList (java.util.ArrayList)70 List (java.util.List)61 HashMap (java.util.HashMap)60 Test (org.junit.Test)46 IOException (java.io.IOException)38 Collection (java.util.Collection)35 DecodeHintType (com.google.zxing.DecodeHintType)30 HashSet (java.util.HashSet)26 Set (java.util.Set)26 EncodeHintType (com.google.zxing.EncodeHintType)17 File (java.io.File)17 BitMatrix (com.google.zxing.common.BitMatrix)15 BookID (biblemulticonverter.data.BookID)14 Iterator (java.util.Iterator)14 URL (java.net.URL)12 TreeMap (java.util.TreeMap)12 Header (com.jsql.model.bean.util.Header)10 Request (com.jsql.model.bean.util.Request)10