This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import unittest | |
import hello | |
# Initialize a class to use with unittest framework | |
class HelloTest(unittest.TestCase): | |
# Test the hello world function from hello.py | |
def testHelloWorld(self): | |
# check whether the 'hello world' is returned by the method | |
self.assertEqual(hello.helloWorld(), 'hello world') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test: | |
image: python:3.7 | |
script: | |
- python -m unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
test: | |
image: python:3.7 | |
script: | |
- python -m unittest | |
production: | |
script: | |
- tar -czvf release.tar.gz *.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- test | |
- production | |
test: | |
stage: test | |
image: python:3.7 | |
script: | |
- python -m unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class App extends Application { | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
primaryStage.setTitle("JavaFX Realtime Chart Demo"); | |
// show the stage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//defining the axes | |
final CategoryAxis xAxis = new CategoryAxis(); // we are gonna plot against time | |
final NumberAxis yAxis = new NumberAxis(); | |
xAxis.setLabel("Time/s"); | |
xAxis.setAnimated(false); // axis animations are removed | |
yAxis.setLabel("Value"); | |
yAxis.setAnimated(false); // axis animations are removed | |
//creating the line chart with two axis created above | |
final LineChart<String, Number> lineChart = new LineChart<>(xAxis, yAxis); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//defining a series to display data | |
XYChart.Series<String, Number> series = new XYChart.Series<>(); | |
series.setName("Data Series"); | |
// add series to chart | |
lineChart.getData().add(series); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// setup scene | |
Scene scene = new Scene(lineChart, 800, 600); | |
primaryStage.setScene(scene); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is used to display time in HH:mm:ss format | |
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss"); | |
// setup a scheduled executor to periodically put data into the chart | |
ScheduledExecutorService scheduledExecutorService; | |
scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(); | |
// put dummy data onto graph per second | |
scheduledExecutorService.scheduleAtFixedRate(() -> { | |
// get a random integer between 0-10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void stop() throws Exception { | |
super.stop(); | |
scheduledExecutorService.shutdownNow(); | |
} |