-
Notifications
You must be signed in to change notification settings - Fork 13
[bf #331] raising exceptions when poly ill defined #332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ebd494b
a0f432b
9b83143
967e02a
ea9d745
8d67f90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # cython: boundscheck=False | ||
| # cython: wraparound=False | ||
| # cython: cdivision=True | ||
| # cython: initializedcheck=False | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this flag do ?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cython normally checks if a memory view is initialized before using it. This turns the verification off (for speed purposes). I wanted to match the flags with the GG file. |
||
| # | ||
| ################################################################################ | ||
| # Utility functions for basic geometry : | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2203,8 +2203,8 @@ def _get_largs_dsino(): | |
|
|
||
| def _checkformat_inputs_Struct(self, struct, err=True): | ||
| assert issubclass(struct.__class__, Struct) | ||
| C0 = struct.Id.Exp==self.Id.Exp | ||
| C1 = struct.Id.Type==self.Id.Type | ||
| C0 = struct.Id.Exp == self.Id.Exp | ||
| C1 = struct.Id.Type == self.Id.Type | ||
| C2 = struct.Id.Name.isidentifier() | ||
| C2 = C2 and '_' not in struct.Id.Name | ||
| msgi = None | ||
|
|
@@ -3134,7 +3134,6 @@ def plot_phithetaproj_dist(self, refpt=None, ntheta=None, nphi=None, | |
| tit=tit, wintit=wintit, | ||
| invertx=invertx, draw=draw) | ||
|
|
||
|
|
||
| def isInside(self, pts, In="(X,Y,Z)", log="any"): | ||
|
|
||
| """ Return a 2D array of bool | ||
|
|
@@ -3728,7 +3727,7 @@ def _checkformat_inputs_dgeom(self, dgeom=None): | |
| if (isinstance(dgeom, self._dcases[k]['type']) | ||
| and all([kk in dgeom.keys() # noqa | ||
| for kk in self._dcases[k]['lk']]))] | ||
| if not len(lC)==1: | ||
| if not len(lC) == 1: | ||
| lstr = [v['lk'] for v in self._dcases.values()] | ||
| msg = "Arg dgeom must be either:\n" | ||
| msg += " - dict with keys:\n" | ||
|
|
@@ -4141,7 +4140,8 @@ def _complete_dX12(self, dgeom): | |
| k = np.sum(DDb*(u - np.sqrt(sca2)*dgeom['u'][:, 1:]), | ||
| axis=0) | ||
| k = k / (1.0-sca2) | ||
| if k[0] > 0 and np.allclose(k, k[0], atol=1.e-3, rtol=1.e-6): | ||
| if k[0] > 0 and np.allclose(k, k[0], atol=1.e-3, | ||
| rtol=1.e-6): | ||
| pinhole = dgeom['D'][:, 0] + k[0]*u[:, 0] | ||
| dgeom['pinhole'] = pinhole | ||
|
|
||
|
|
@@ -5033,8 +5033,8 @@ def D(self): | |
|
|
||
| @property | ||
| def u(self): | ||
| if (self._dgeom['u'] is not None | ||
| and self._dgeom['u'].shape[1] == self._dgeom['nRays']): | ||
| if self._dgeom['u'] is not None \ | ||
| and self._dgeom['u'].shape[1] == self._dgeom['nRays']: | ||
| u = self._dgeom['u'] | ||
| elif self.isPinhole: | ||
| u = self._dgeom['pinhole'][:, None] - self._dgeom['D'] | ||
|
|
@@ -5127,7 +5127,7 @@ def _isLOS(cls): | |
| def _check_indch(self, ind, out=int): | ||
| if ind is not None: | ||
| ind = np.asarray(ind) | ||
| assert ind.ndim==1 | ||
| assert ind.ndim == 1 | ||
| assert ind.dtype in [np.int64, np.bool_, np.long] | ||
| if ind.dtype == np.bool_: | ||
| assert ind.size == self.nRays | ||
|
|
@@ -5574,17 +5574,17 @@ def _kInOut_Isoflux_inputs_usr(self, lPoly, lVIn=None): | |
| if type(lPoly) is list: | ||
| for ii in range(nPoly): | ||
| # Check closed and anti-clockwise | ||
| if _GG.Poly_isClockwise(lPoly[ii]): | ||
| lPoly[ii] = lPoly[ii][:, ::-1] | ||
| if not np.allclose(lPoly[ii][:, 0], lPoly[ii][:, -1]): | ||
| lPoly[ii] = np.concatenate( | ||
| (lPoly[ii], lPoly[ii][:, 0:1]), axis=-1 | ||
| ) | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. first we close the poly then we check if clockwise |
||
| try: | ||
| if _GG.Poly_isClockwise(lPoly[ii]): | ||
| lPoly[ii] = lPoly[ii][:, ::-1] | ||
| except Exception as excp: | ||
| print("For structure ", ii, " : ", excp) | ||
| else: | ||
| for ii in range(nPoly): | ||
| # Check closed and anti-clockwise | ||
| if _GG.Poly_isClockwise(lPoly[ii]): | ||
| lPoly[ii] = lPoly[ii][:, ::-1] | ||
| # Check closed and anti-clockwise | ||
| d = np.sum((lPoly[:, :, 0]-lPoly[:, :, -1])**2, axis=1) | ||
| if np.allclose(d, 0.): | ||
| pass | ||
|
|
@@ -5593,6 +5593,12 @@ def _kInOut_Isoflux_inputs_usr(self, lPoly, lVIn=None): | |
| else: | ||
| msg = "All poly in lPoly should be closed or all non-closed!" | ||
| raise Exception(msg) | ||
| for ii in range(nPoly): | ||
| try: | ||
| if _GG.Poly_isClockwise(lPoly[ii]): | ||
| lPoly[ii] = lPoly[ii][:, ::-1] | ||
| except Exception as excp: | ||
| print("For structure ", ii, " : ", excp) | ||
|
|
||
| # Check lVIn | ||
| if lVIn is None: | ||
|
|
@@ -5663,14 +5669,14 @@ def calc_kInkOut_Isoflux(self, lPoly, lVIn=None, Lim=None, | |
|
|
||
| # Compute intersections | ||
| assert(self._method in ['ref', 'optimized']) | ||
| if self._method=='ref': | ||
| if self._method == 'ref': | ||
| for ii in range(0, nPoly): | ||
| largs, dkwd = self._kInOut_Isoflux_inputs([lPoly[ii]], | ||
| lVIn=[lVIn[ii]]) | ||
| out = _GG.SLOW_LOS_Calc_PInOut_VesStruct(*largs, **dkwd) | ||
| # PIn, POut, kin, kout, VperpIn, vperp, IIn, indout = out[] | ||
| kIn[ii, :], kOut[ii, :] = out[2], out[3] | ||
| elif self._method=="optimized": | ||
| elif self._method == "optimized": | ||
| for ii in range(0, nPoly): | ||
| largs, dkwd = self._kInOut_Isoflux_inputs([lPoly[ii]], | ||
| lVIn=[lVIn[ii]]) | ||
|
|
@@ -6900,7 +6906,7 @@ def get_summary( | |
| # Prepare | ||
| kout = self._dgeom["kOut"] | ||
| indout = self._dgeom["indout"] | ||
| lS = self._dconfig["Config"].lStruct | ||
| # lS = self._dconfig["Config"].lStruct | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is not being used, so I commented it |
||
| angles = np.arccos(-np.sum(self.u*self.dgeom['vperp'], axis=0)) | ||
|
|
||
| # ar0 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| # Do not edit, pipeline versioning governed by git tags! | ||
| __version__ = '1.4.2-a5-113-gcbcc34c7' | ||
| __version__ = '1.4.2b13-65-ga0f432bb' |
Uh oh!
There was an error while loading. Please reload this page.