[cig-commits] [commit] master: Add [] operators to SWIG (a163023)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Wed Oct 8 17:06:26 PDT 2014


Repository : https://github.com/geodynamics/vc

On branch  : master
Link       : https://github.com/geodynamics/vc/compare/23464fca3efa2b6ad7ee0ce8f60c225b18b49741...e4325192ad1118379f46ba66899cb98143d09e04

>---------------------------------------------------------------

commit a163023bb17ca4ca903b0e43418ef4a429e12526
Author: Eric Heien <emheien at ucdavis.edu>
Date:   Fri Oct 3 16:31:15 2014 -0700

    Add [] operators to SWIG


>---------------------------------------------------------------

a163023bb17ca4ca903b0e43418ef4a429e12526
 quakelib/python/quakelib.i | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/quakelib/python/quakelib.i b/quakelib/python/quakelib.i
index be8ac40..3ae200d 100644
--- a/quakelib/python/quakelib.i
+++ b/quakelib/python/quakelib.i
@@ -178,6 +178,9 @@ using namespace quakelib;
 		sprintf(tmp, "<quakelib::Tensor<3,3> at %p>", $self);
 		return tmp;
 	}
+
+    TensorRow<3> __getitem__(unsigned int i) throw(std::out_of_range) { return (*$self)[i]; };
+	void __setitem__(unsigned int i, TensorRow<3> new_val) throw(std::out_of_range) { (*$self)[i] = new_val; };
 };
 
 %extend quakelib::TensorRow<3> {
@@ -197,6 +200,9 @@ using namespace quakelib;
 		sprintf(tmp, "<quakelib::TensorRow<3> at %p>", $self);
 		return tmp;
 	}
+
+    double __getitem__(unsigned int i) throw(std::out_of_range) { return (*$self)[i]; };
+	void __setitem__(unsigned int i, double new_val) throw(std::out_of_range) { (*$self)[i] = new_val; };
 };
 
 %extend quakelib::RectBound<2> {



More information about the CIG-COMMITS mailing list