Skip to content

Commit

Permalink
Fix minor formatting and move remaining make test to PottsCellStem
Browse files Browse the repository at this point in the history
  • Loading branch information
jessicasyu committed Jul 30, 2024
1 parent 56d0281 commit 20cd228
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 57 deletions.
2 changes: 1 addition & 1 deletion src/arcade/potts/agent/cell/PottsCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public void setState(CellState newState) {
* @param newState the cell state
*/
abstract void setStateModule(CellState newState);

@Override
public void schedule(Schedule schedule) {
stopper = schedule.scheduleRepeating(this, Ordering.CELLS.ordinal(), 1);
Expand Down
18 changes: 9 additions & 9 deletions src/arcade/potts/agent/cell/PottsCellStem.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,25 @@ public final class PottsCellStem extends PottsCell {
* @param criticalRegionHeights the map of critical heights for regions
*/
public PottsCellStem(int id, int parent, int pop, CellState state, int age, int divisions,
Location location, boolean hasRegions, MiniBox parameters,
double criticalVolume, double criticalHeight,
EnumMap<Region, Double> criticalRegionVolumes,
EnumMap<Region, Double> criticalRegionHeights) {
Location location, boolean hasRegions, MiniBox parameters,
double criticalVolume, double criticalHeight,
EnumMap<Region, Double> criticalRegionVolumes,
EnumMap<Region, Double> criticalRegionHeights) {
super(id, parent, pop, state, age, divisions, location, hasRegions, parameters,
criticalVolume, criticalHeight, criticalRegionVolumes, criticalRegionHeights);
}

@Override
public PottsCell make(int newID, CellState newState, Location newLocation,
MersenneTwisterFast random) {
MersenneTwisterFast random) {
divisions++;
return new PottsCellStem(newID, id, pop, newState, age, divisions, newLocation,
hasRegions, parameters, criticalVolume, criticalHeight,
criticalRegionVolumes, criticalRegionHeights);
hasRegions, parameters, criticalVolume, criticalHeight,
criticalRegionVolumes, criticalRegionHeights);
}

@Override
public void setStateModule(CellState newState) {
void setStateModule(CellState newState) {
switch ((State) newState) {
case QUIESCENT:
module = new PottsModuleQuiescence(this);
Expand Down
7 changes: 4 additions & 3 deletions src/arcade/potts/sim/PottsSeries.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public final class PottsSeries extends Series {

/** Default cell class. */
public static final String DEFAULT_CELL_CLASS = "stem";

/** Map of potts settings. */
public MiniBox potts;

Expand Down Expand Up @@ -190,8 +190,9 @@ protected void updatePopulations(ArrayList<Box> populationsBox, MiniBox populati
if (populationClass == null) {
populationClass = DEFAULT_CELL_CLASS;
}
//TODO: Use logger to print message when default class is used.


// TODO: Use logger to print message when default class is used.

Check failure on line 194 in src/arcade/potts/sim/PottsSeries.java

View workflow job for this annotation

GitHub Actions / checkstyle

[checkstyle] src/arcade/potts/sim/PottsSeries.java#L194 <com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck>

Comment matches to-do format 'TODO:'.
Raw output
/github/workspace/./src/arcade/potts/sim/PottsSeries.java:194:15: error: Comment matches to-do format 'TODO:'. (com.puppycrawl.tools.checkstyle.checks.TodoCommentCheck)

// Create new population and update code.
MiniBox population = new MiniBox();
population.put("CODE", code++);
Expand Down
32 changes: 26 additions & 6 deletions test/arcade/potts/agent/cell/PottsCellStemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ public class PottsCellStemTest {

static State cellState = State.QUIESCENT;

static PottsCell cellDefault;

static PottsCell cellWithRegions;

static PottsCell cellWithoutRegions;

static EnumSet<Region> regionList;

static MiniBox parametersMock;
Expand Down Expand Up @@ -176,6 +170,32 @@ public void setState_invalidState_setsNull() {
assertNull(cell.getModule());
}

@Test
public void make_noRegions_setsFields() {
double criticalVolume = randomDoubleBetween(10, 100);
double criticalHeight = randomDoubleBetween(10, 100);
MiniBox parameters = mock(MiniBox.class);
Location location1 = mock(PottsLocation.class);
Location location2 = mock(PottsLocation.class);

PottsCellStem cell1 = new PottsCellStem(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions,
location1, false, parameters, criticalVolume, criticalHeight,
null, null);
PottsCellStem cell2 = (PottsCellStem) cell1.make(cellID + 1, State.QUIESCENT, location2, null);

assertEquals(cellID + 1, cell2.id);
assertEquals(cellID, cell2.parent);
assertEquals(cellPop, cell2.pop);
assertEquals(cellAge, cell2.getAge());
assertEquals(cellDivisions + 1, cell1.getDivisions());
assertEquals(cellDivisions + 1, cell2.getDivisions());
assertFalse(cell2.hasRegions());
assertEquals(location2, cell2.getLocation());
assertEquals(cell2.parameters, parameters);
assertEquals(criticalVolume, cell2.getCriticalVolume(), EPSILON);
assertEquals(criticalHeight, cell2.getCriticalHeight(), EPSILON);
}

@Test
public void make_hasRegions_setsFields() {
double criticalVolume = randomDoubleBetween(10, 100);
Expand Down
45 changes: 8 additions & 37 deletions test/arcade/potts/agent/cell/PottsCellTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,27 @@ public class PottsCellTest {
static EnumSet<Region> regionList;

static MiniBox parametersMock;

static class PottsCellMock extends PottsCell {
PottsCellMock(int id, int parent, int pop, CellState state, int age, int divisions,
Location location, boolean hasRegions, MiniBox parameters,
double criticalVolume, double criticalHeight,
EnumMap<Region, Double> criticalRegionVolumes,
EnumMap<Region, Double> criticalRegionHeights) {
super(id, parent, pop, state, age, divisions, location, hasRegions, parameters,
criticalVolume, criticalHeight, criticalRegionVolumes, criticalRegionHeights);

criticalVolume, criticalHeight, criticalRegionVolumes, criticalRegionHeights);
}

@Override
public PottsCellMock make(int newID, CellState newState, Location newLocation,
MersenneTwisterFast random) {
MersenneTwisterFast random) {
return new PottsCellMock(newID, id, pop, newState, age, divisions, newLocation,
hasRegions, parameters, criticalVolume, criticalHeight,
criticalRegionVolumes, criticalRegionHeights);
hasRegions, parameters, criticalVolume, criticalHeight,
criticalRegionVolumes, criticalRegionHeights);
}

@Override
public void setStateModule(CellState newState) {
void setStateModule(CellState newState) {
module = mock(PottsModule.class);
}
}
Expand Down Expand Up @@ -162,7 +161,7 @@ static PottsCell make(boolean regions) {
return make(locationMock, regions);
}

static PottsCellMock make(Location location, boolean regions) {
static PottsCell make(Location location, boolean regions) {
if (!regions) {
return new PottsCellMock(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions,
location, false, parametersMock, cellCriticalVolume, cellCriticalHeight,
Expand Down Expand Up @@ -587,32 +586,6 @@ public void stop_called_callsMethod() {
verify(cell.stopper).stop();
}

@Test
public void make_noRegions_setsFields() {
double criticalVolume = randomDoubleBetween(10, 100);
double criticalHeight = randomDoubleBetween(10, 100);
MiniBox parameters = mock(MiniBox.class);
Location location1 = mock(PottsLocation.class);
Location location2 = mock(PottsLocation.class);

PottsCell cell1 = new PottsCellStem(cellID, cellParent, cellPop, cellState, cellAge, cellDivisions,
location1, false, parameters, criticalVolume, criticalHeight,
null, null);
PottsCell cell2 = (PottsCellStem) cell1.make(cellID + 1, State.QUIESCENT, location2, null);

assertEquals(cellID + 1, cell2.id);
assertEquals(cellID, cell2.parent);
assertEquals(cellPop, cell2.pop);
assertEquals(cellAge, cell2.getAge());
assertEquals(cellDivisions + 1, cell1.getDivisions());
assertEquals(cellDivisions + 1, cell2.getDivisions());
assertFalse(cell2.hasRegions());
assertEquals(location2, cell2.getLocation());
assertEquals(cell2.parameters, parameters);
assertEquals(criticalVolume, cell2.getCriticalVolume(), EPSILON);
assertEquals(criticalHeight, cell2.getCriticalHeight(), EPSILON);
}

@Test
public void schedule_validInput_callsMethod() {
Schedule schedule = spy(mock(Schedule.class));
Expand Down Expand Up @@ -1047,9 +1020,8 @@ public void convert_noRegions_createsContainer() {
PottsCell cell = new PottsCellMock(id, parent, pop, state, age, divisions, location,
false, parameters, criticalVolume, criticalHeight,
null, null);

doReturn(phase).when((PottsModule) cell.getModule()).getPhase();

int voxels = randomIntBetween(1, 100);
doReturn((double) voxels).when(location).getVolume();

Expand Down Expand Up @@ -1094,7 +1066,6 @@ public void convert_withRegions_createsContainer() {
PottsCell cell = new PottsCellMock(id, parent, pop, state, age, divisions, location, true,
parameters, criticalVolume, criticalHeight,
criticalRegionVolumes, criticalRegionHeights);

doReturn(phase).when((PottsModule) cell.getModule()).getPhase();

int voxels = randomIntBetween(1, 100);
Expand Down
1 change: 0 additions & 1 deletion test/arcade/potts/sim/PottsSeriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import arcade.core.util.MiniBox;
import arcade.potts.vis.PottsVisualization;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static arcade.core.ARCADETestUtilities.*;
import static arcade.core.util.MiniBox.TAG_SEPARATOR;
Expand Down

0 comments on commit 20cd228

Please sign in to comment.