diff --git a/eo/src/eoVariableLengthCrossover.h b/eo/src/eoVariableLengthCrossover.h index 1d1eaf82..db569625 100644 --- a/eo/src/eoVariableLengthCrossover.h +++ b/eo/src/eoVariableLengthCrossover.h @@ -21,7 +21,7 @@ Contact: todos@geneura.ugr.es, http://geneura.ugr.es Marc.Schoenauer@polytechnique.fr mak@dhi.dk - CVS Info: $Date: 2003-02-27 19:25:48 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.8 2003-02-27 19:25:48 okoenig Exp $ $Author: okoenig $ + CVS Info: $Date: 2003-03-21 02:38:57 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoVariableLengthCrossover.h,v 1.9 2003-03-21 02:38:57 maartenkeijzer Exp $ $Author: maartenkeijzer $ */ //----------------------------------------------------------------------------- @@ -150,10 +150,17 @@ public : virtual std::string className() const { +#ifdef HAVE_SSTREAM + std::ostringstream os; + os << "eoVlAtomExchangeQuadOp(" << atomExchange.className() << ")"; + return os.str() +#else + char s[1024]; std::ostrstream os(s, 1022); os << "eoVlAtomExchangeQuadOp(" << atomExchange.className() << ")" << std::ends; return std::string(s); +#endif } private: diff --git a/eo/src/eoVariableLengthMutation.h b/eo/src/eoVariableLengthMutation.h index 949b5d9a..30b1d3b0 100644 --- a/eo/src/eoVariableLengthMutation.h +++ b/eo/src/eoVariableLengthMutation.h @@ -21,7 +21,7 @@ Contact: todos@geneura.ugr.es, http://geneura.ugr.es Marc.Schoenauer@polytechnique.fr mak@dhi.dk - CVS Info: $Date: 2003-02-27 19:25:48 $ $Version$ $Author: okoenig $ + CVS Info: $Date: 2003-03-21 02:38:57 $ $Version$ $Author: maartenkeijzer $ */ //----------------------------------------------------------------------------- @@ -140,11 +140,17 @@ public : } virtual std::string className() const - { + { +#ifdef HAVE_SSTREAM + std::ostringstream os; + os << "eoVlDelMutation("<(pickled[0]); + rng_from_string(_rng, state); + } +}; + int spin(eoRng& _rng, numeric::array values, double total) { if (total == 0.0) @@ -97,6 +113,7 @@ void random_numbers() .def("to_string", rng_to_string) .def("from_string", rng_from_string) .def("roulette_wheel", spin) + .def_pickle(RNG_pickle_suite()) ; def("rng", get_rng, return_value_policy()); diff --git a/eo/src/pyeo/test/test_pickling.py b/eo/src/pyeo/test/test_pickling.py index dbe36bc2..161668bb 100644 --- a/eo/src/pyeo/test/test_pickling.py +++ b/eo/src/pyeo/test/test_pickling.py @@ -69,28 +69,7 @@ class TestPickling(unittest.TestCase): for i in range(10): rng().rand() - filename = tempfile.mktemp() - file = open(filename, 'wb') - pickler = cPickle.Pickler(file) - - s = rng().to_string() - - pickler.dump(s); - del pickler - file.close() - - file = open(filename) - - unpickler = cPickle.Unpickler(file) - - s = unpickler.load() - - rng2 = eoRng(1) - rng2.from_string(s) - - del unpickler - file.close() - os.remove(filename) + rng2 = self.do_pickle(rng()) for i in range(100): a = rng().rand() @@ -99,19 +78,7 @@ class TestPickling(unittest.TestCase): def vParam(self,v): - filename = tempfile.mktemp() - file = open(filename,'wb') - pickler = cPickle.Pickler(file) - - pickler.dump(v) - del pickler - file.close() - file = open(filename) - - unpickler = cPickle.Unpickler(file) - - v2 = unpickler.load(); - + v2 = self.do_pickle(v); self.failUnlessEqual(v.value, v2.value) def testValueParam(self): diff --git a/eo/src/utils/eoFileSnapshot.h b/eo/src/utils/eoFileSnapshot.h index 0c89ef7e..67182d79 100644 --- a/eo/src/utils/eoFileSnapshot.h +++ b/eo/src/utils/eoFileSnapshot.h @@ -97,12 +97,13 @@ public : { #ifdef HAVE_SSTREAM std::ostringstream oscount; + oscount << counter; #else char buff[255]; std::ostrstream oscount(buff, 254); -#endif oscount << counter; oscount << std::ends; +#endif currentFileName = dirname + "/" + filename + oscount.str(); } diff --git a/eo/src/utils/eoGnuplot.h b/eo/src/utils/eoGnuplot.h index 38aea2b4..b06cba51 100644 --- a/eo/src/utils/eoGnuplot.h +++ b/eo/src/utils/eoGnuplot.h @@ -106,12 +106,13 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) { #ifdef HAVE_SSTREAM std::ostringstream os; + os << "300x200-0+" << numWindow*220; #else char snum[255]; std::ostrstream os(snum, 254); + os << "300x200-0+" << numWindow*220 << std::ends; #endif - os << "300x200-0+" << numWindow*220 << std::ends; numWindow++; char *args[6]; args[0] = strdup( "gnuplot" ); @@ -148,7 +149,7 @@ inline void eoGnuplot::initGnuPlot(std::string _title, std::string _extra) * Created......: Mon Mar 13 13:50:11 1995 * Description..: Communication par pipe bidirectionnel avec un autre process * - * Ident........: $Id: eoGnuplot.h,v 1.7 2003-02-28 16:49:14 maartenkeijzer Exp $ + * Ident........: $Id: eoGnuplot.h,v 1.8 2003-03-21 02:39:09 maartenkeijzer Exp $ * ---------------------------------------------------------------------- */ diff --git a/eo/src/utils/eoGnuplot1DMonitor.h b/eo/src/utils/eoGnuplot1DMonitor.h index 9bc9261d..8ab8082a 100644 --- a/eo/src/utils/eoGnuplot1DMonitor.h +++ b/eo/src/utils/eoGnuplot1DMonitor.h @@ -120,10 +120,10 @@ inline void eoGnuplot1DMonitor::FirstPlot() os << ", "; } os << '\n'; - os << std::ends; #ifdef HAVE_SSTREAM PipeComSend( gpCom, os.str().c_str()); #else + os << std::ends; PipeComSend( gpCom, buff ); #endif } diff --git a/eo/src/utils/eoHowMany.h b/eo/src/utils/eoHowMany.h index 696a701e..95f36c67 100644 --- a/eo/src/utils/eoHowMany.h +++ b/eo/src/utils/eoHowMany.h @@ -132,9 +132,9 @@ public: virtual void printOn(std::ostream& _os) const { if (combien == 0) - _os << 100*rate << "% " << std::ends; + _os << 100*rate << "% "; else - _os << combien << " " << std::ends; + _os << combien << " "; return; } diff --git a/eo/src/utils/eoParam.h b/eo/src/utils/eoParam.h index c1f75092..921d85e2 100644 --- a/eo/src/utils/eoParam.h +++ b/eo/src/utils/eoParam.h @@ -164,12 +164,13 @@ public : { #ifdef HAVE_SSTREAM std::ostringstream os; + os << repValue; #else char buf[1024]; std::ostrstream os(buf, 1023); -#endif os << repValue; os << std::ends; +#endif return os.str(); } @@ -221,11 +222,12 @@ std::string eoValueParam >::getValue(void) const // use own buffer as MSVC's buffer leaks! #ifdef HAVE_SSTREAM std::ostringstream os; + os << repValue.first << ' ' << repValue.second; #else char buff[1024]; std::ostrstream os(buff, 1024); -#endif os << repValue.first << ' ' << repValue.second << std::ends; +#endif return os.str(); } @@ -260,7 +262,9 @@ std::string eoValueParam > >::getValue(void) con std::copy(repValue[i].begin(), repValue[i].end(), std::ostream_iterator(os, " ")); } +#ifndef HAVE_SSTREAM os << std::ends; +#endif return os.str(); } @@ -302,7 +306,9 @@ std::string eoValueParam >::getValue(void) const #endif os << repValue.size() << ' '; std::copy(repValue.begin(), repValue.end(), std::ostream_iterator(os, " ")); +#ifndef HAVE_SSTREAM os << std::ends; +#endif return os.str(); } @@ -334,7 +340,9 @@ std::string eoValueParam >::getValue(void) cons #endif os << repValue.size() << ' '; std::copy(repValue.begin(), repValue.end(), std::ostream_iterator(os, " ")); - os << std::ends; +#ifndef HAVE_SSTREAM + os<< std::ends; +#endif return os.str(); } diff --git a/eo/src/utils/eoPopStat.h b/eo/src/utils/eoPopStat.h index 4c06f2d5..f607590f 100644 --- a/eo/src/utils/eoPopStat.h +++ b/eo/src/utils/eoPopStat.h @@ -70,7 +70,7 @@ void operator()(const eoPop& _pop) for (unsigned i = 0; i < howmany; ++i) { std::ostringstream os; - os << _pop[i] << std::endl << std::ends; + os << _pop[i] << std::endl; // paranoid: value() += os.str(); @@ -130,8 +130,8 @@ public : unsigned howMany=combien?combien:_pop.size(); for (unsigned i = 0; i < howMany; ++i) { - std::ostringstream os; // leave space for emergency terminate - os << *_pop[i] << std::endl << std::ends; + std::ostringstream os; + os << *_pop[i] << std::endl; // paranoid: value() += os.str();