Skip to content

Commit

Permalink
Now we a new CPP class timeseries
Browse files Browse the repository at this point in the history
  • Loading branch information
scottcoughlin2014 committed Aug 26, 2020
1 parent 095f0d8 commit 6668ccd
Show file tree
Hide file tree
Showing 10 changed files with 25,070 additions and 1 deletion.
26 changes: 26 additions & 0 deletions python_tutorial/tests/test_mammal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright (C) Scott Coughlin (2019)
#
# This file is part of python_tutorial.
#
# python_tutorial is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# python_tutorial is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with python_tutorial. If not, see <http://www.gnu.org/licenses/>.

"""Unit test for python_tutorial.YOURMODULE classes
"""

from python_tutorial.rectangle import PyRectangle

class TestPyRectangle(object):
def test_get_area(self):
assert 4 == PyRectangle(0,0,2,2).get_area()
26 changes: 26 additions & 0 deletions python_tutorial/tests/test_rectangle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright (C) Scott Coughlin (2019)
#
# This file is part of python_tutorial.
#
# python_tutorial is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# python_tutorial is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with python_tutorial. If not, see <http://www.gnu.org/licenses/>.

"""Unit test for python_tutorial.YOURMODULE classes
"""

from python_tutorial.rectangle import PyRectangle

class TestPyRectangle(object):
def test_get_area(self):
assert 4 == PyRectangle(0,0,2,2).get_area()
20 changes: 20 additions & 0 deletions python_tutorial/timeseries/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) Scott Coughlin (2019)
#
# This file is part of python_tutorial
#
# python_tutorial is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# python_tutorial is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with python_tutorial. If not, see <http://www.gnu.org/licenses/>

from .timeseries import PyTimeSeries
24 changes: 24 additions & 0 deletions python_tutorial/timeseries/src/TimeSeries.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <iostream>
#include "TimeSeries.h"

namespace timeseries {

// Default constructor
TimeSeries::TimeSeries () {}

// Overloaded constructor
TimeSeries::TimeSeries (double* series, int size, double* xindex, double* dydx) {
this->series = series;
this->xindex = xindex;
this->dydx = dydx;
this->size = size;
this->x0 = series[0];
}

// Destructor
TimeSeries::~TimeSeries () {}

double TimeSeries::getDT () {
return (this->xindex[1] - this->xindex[0]);
}
}
19 changes: 19 additions & 0 deletions python_tutorial/timeseries/src/TimeSeries.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef TIMESERIES_H
#define TIMESERIES_H

namespace timeseries {
class TimeSeries {
public:
double x0;
int size;
double* series;
double* xindex;
double* dydx;
TimeSeries();
TimeSeries(double* series, int size, double* xindex, double* dydx);
~TimeSeries();
double getDT();
};
}

#endif
12 changes: 12 additions & 0 deletions python_tutorial/timeseries/src/TimeSeries.pxd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# distutils: sources = python_tutorial/rectangle/src/TimeSeries.cpp

cdef extern from "TimeSeries.h" namespace "timeseries":
cdef cppclass TimeSeries:
TimeSeries() except +
TimeSeries(double [], int, double [], double []) except +
double x0
double* series
double* xindex
double* dydx
int size
double getDT()
Empty file.
Loading

0 comments on commit 6668ccd

Please sign in to comment.