Skip to content

Commit

Permalink
fix some compiler warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
virgesmith committed Oct 21, 2020
1 parent 47ad6c3 commit d62f4ce
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 27 deletions.
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def cxxflags(platform):

if platform == "unix":
return [
"-Wall",
"-Werror",
"-pedantic",
"-pthread",
"-Wsign-compare",
"-fstack-protector-strong",
Expand Down
4 changes: 2 additions & 2 deletions src/DataFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ void no::df::transition(no::Model& model, py::array_t<int64_t> categories, py::a
}

// reverse catgory lookup
std::map<int64_t, int> lookup;
std::map<int64_t, int64_t> lookup;
for (py::ssize_t i = 0; i < m; ++i)
{
lookup[no::at<int64_t>(categories, Index_t<1>{i})] = (int64_t)i;
lookup[no::at<int64_t>(categories, Index_t<1>{i})] = i;
}

py::ssize_t n = col.size();
Expand Down
12 changes: 6 additions & 6 deletions src/Error.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
const char* no::NotImplementedError::what() const noexcept
{
return m_msg.c_str();
}
}


// map error types defined here to python exceptions
void no::exception_translator(std::exception_ptr p)
void no::exception_translator(std::exception_ptr p)
{
try
try
{
if (p) std::rethrow_exception(p);
}
catch (const no::NotImplementedError& e)
}
catch (const no::NotImplementedError& e)
{
PyErr_SetString(PyExc_NotImplementedError, e.what());
}
};
}
2 changes: 1 addition & 1 deletion src/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ bool no::Model::run(py::object& model_subclass)
{
base.timeline().next();
double t = base.timeline().time();
int timeindex = base.timeline().index();
size_t timeindex = base.timeline().index();

no::log("t=%%(%%) %%.step()"s % t % timeindex % subclass_name);
model_subclass.attr("step")();
Expand Down
10 changes: 5 additions & 5 deletions src/MonteCarlo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ void validate_lambda(const py::array_t<double>& lambda)


// helper functions for basic seeding strategies
int64_t no::MonteCarlo::deterministic_independent_stream(int r)
int32_t no::MonteCarlo::deterministic_independent_stream(int r)
{
return 19937 + r;
}

int64_t no::MonteCarlo::deterministic_identical_stream(int)
int32_t no::MonteCarlo::deterministic_identical_stream(int)
{
return 19937;
}

int64_t no::MonteCarlo::nondeterministic_stream(int)
int32_t no::MonteCarlo::nondeterministic_stream(int)
{
std::random_device rand;
return (static_cast<int64_t>(rand()) << 32) + rand();
return rand();
}

//
no::MonteCarlo::MonteCarlo(int64_t seed)
no::MonteCarlo::MonteCarlo(int32_t seed)
: m_seed(seed), m_prng(m_seed) { }


Expand Down
18 changes: 9 additions & 9 deletions src/MonteCarlo.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ class NEWORDER_EXPORT MonteCarlo
public:

// some basic seeding strategies
static int64_t deterministic_independent_stream(int r);
static int32_t deterministic_independent_stream(int r);

static int64_t deterministic_identical_stream(int);
static int32_t deterministic_identical_stream(int);

static int64_t nondeterministic_stream(int);
static int32_t nondeterministic_stream(int);

// constructs given a seed
MonteCarlo(int64_t seed);
MonteCarlo(int32_t seed);

int64_t seed() const;

Expand All @@ -44,19 +44,19 @@ class NEWORDER_EXPORT MonteCarlo
// raw unsigned 64-bit ints, can be used to (un)deterministically seed another generator (e.g. np.random)
uint64_t raw();

// randomly sample categories with weights
// randomly sample categories with weights
py::array_t<int64_t> sample(py::ssize_t n, const py::array_t<double>& cat_weights);

// single-prob hazard
// single-prob hazard
py::array_t<double> hazard(double prob, py::ssize_t n);

// vector hazard
// vector hazard
py::array_t<double> hazard(const py::array_t<double>& prob);

// compute stopping times
// compute stopping times
py::array_t<double> stopping(double prob, py::ssize_t n);

// vector stopping
// vector stopping
py::array_t<double> stopping(const py::array_t<double>& prob);

// multiple-arrival (0+) process (requires that final hazard rate is zero)
Expand Down
8 changes: 4 additions & 4 deletions src/Timeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace no {

class Timeline final
class NEWORDER_EXPORT Timeline final
{
public:

Expand Down Expand Up @@ -44,16 +44,16 @@ class Timeline final
std::string repr() const;

private:
double m_start;
double m_start;
double m_end;

size_t m_index; // index of current time

std::vector<size_t> m_checkpoints;
};

namespace time {

// returns a floating point number that compares unequal (and unordered) to any other number
// thus the following all evaluate to true: never() != never(), !(x < never()), !(x >= never()) (so be careful!)
double never();
Expand Down

0 comments on commit d62f4ce

Please sign in to comment.