Skip to content

Commit 90d1451

Browse files
committed
[Project] Minor project content polishing
1 parent f0479e7 commit 90d1451

10 files changed

+75
-46
lines changed

CODE_OF_CONDUCT.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# JetBrains Open Source and Community Code of Conduct
2+
3+
This code of conduct outlines our expectations for all those who participate in our
4+
open source projects and communities (community programs), as well as the consequences
5+
for unacceptable behaviour. We invite all those who participate to help us create safe
6+
and positive experiences for everyone. Communities mirror the societies in which they
7+
exist and positive action is essential to counteract the many forms of inequality and
8+
abuses of power that exist in society.
9+
10+
## How to behave
11+
12+
The following behaviours are expected and requested of all community members:
13+
14+
- Participate in an authentic and active way. In doing so, you contribute to the health and longevity of this community.
15+
- Exercise consideration, respect and empathy in your speech and actions. Remember, we have all been through different stages of learning when adopting technologies.
16+
- Refrain from demeaning, discriminatory, or harassing behaviour and speech.
17+
- Disagreements on things are fine, argumentative behaviour or trolling are not.
18+
19+
## How not to behave
20+
21+
- Do not perform threats of violence or use violent language directed against another person.
22+
- Do not make jokes of sexist, racist, homophobic, transphobic, ableist or otherwise discriminatory nature, or use language of this nature.
23+
- Do not post or display sexually explicit or violent material.
24+
- Do not post or threaten to post other people’s personally identifying information ("doxing").
25+
- Do not make personal insults, particularly those related to gender, sexual orientation, race, religion, or disability.
26+
- Do not engage in sexual attention. This includes, sexualised comments or jokes and sexual advances.
27+
- Do not advocate for, or encourage, any of the above behaviour.
28+
29+
30+
Please take into account that online communities bring together people from many
31+
different cultures and backgrounds. It's important to understand that sometimes
32+
the combination of cultural differences and online interaction can lead to misunderstandings.
33+
That is why having empathy is very important.
34+
35+
## Also
36+
37+
You can access original text at
38+
[JetBrains Open Source and Community Code of Conduct](https://confluence.jetbrains.com/display/ALL/JetBrains+Open+Source+and+Community+Code+of+Conduct).

README.md

+8-13
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ closure provides info about reachable vertices in the graph:
151151
```c++
152152
/**
153153
* Performs transitive closure for directed graph
154+
*
154155
* @param Inst Library instance, which provides context for operations
155156
* @param A Adjacency matrix of the graph
156157
* @param T Reference to the handle where to allocate and store result
@@ -160,17 +161,15 @@ closure provides info about reachable vertices in the graph:
160161
CuBoolStatus TransitiveClosure(CuBoolInstance Inst, CuBoolMatrix A, CuBoolMatrix* T) {
161162
CuBool_Matrix_Duplicate(Inst, A, T); /** Create result matrix and copy initial values */
162163

163-
CuBoolSize_t total;
164-
CuBool_Matrix_Nvals(Inst, *T, &total); /** Query current number on non-zero elements */
164+
CuBoolSize_t total = 0;
165+
CuBoolSize_t current;
166+
CuBool_Matrix_Nvals(Inst, *T, &current); /** Query current number on non-zero elements */
165167

166-
CuBoolSize_t current = total; /** Loop while values are added */
167-
168-
do {
168+
while (current != total) { /** Loop while values are added */
169169
total = current;
170170
CuBool_MxM(Inst, *T, *T, *T); /** T += T * T */
171171
CuBool_Matrix_Nvals(Inst, *T, &current);
172172
}
173-
while (current != total);
174173

175174
return CUBOOL_STATUS_SUCCESS;
176175
}
@@ -194,17 +193,13 @@ def transitive_closure(a: pycubool.Matrix):
194193
"""
195194
196195
t = a.duplicate() # Duplicate matrix where to store result
196+
total = 0 # Current number of values
197197
198-
total = t.nvals # Current number of values
199-
changing = True # track changing
200-
201-
while changing:
202-
pycubool.mxm(t, t, t) # t += t * t
203-
changing = t.nvals != total
198+
while total != t.nvals:
204199
total = t.nvals
200+
pycubool.mxm(t, t, t) # t += t * t
205201
206202
return t
207-
208203
```
209204

210205
## License

python/pycubool/add.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from . import wrapper
2-
from . import dll
2+
from . import bridge
33
from . import matrix
44

55
__all__ = [
@@ -12,4 +12,4 @@ def add(result_matrix: matrix.Matrix, a_matrix: matrix.Matrix):
1212
result_matrix.hnd,
1313
a_matrix.hnd)
1414

15-
dll.check(status)
15+
bridge.check(status)
File renamed without changes.

python/pycubool/kron.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from . import wrapper
2-
from . import dll
2+
from . import bridge
33
from . import matrix
44

55
__all__ = [
@@ -13,4 +13,4 @@ def kron(result_matrix: matrix.Matrix, a_matrix: matrix.Matrix, b_matrix: matrix
1313
a_matrix.hnd,
1414
b_matrix.hnd)
1515

16-
dll.check(status)
16+
bridge.check(status)

python/pycubool/matrix.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import ctypes
22

33
from . import wrapper
4-
from . import dll
4+
from . import bridge
55

66
__all__ = [
77
"Matrix"
@@ -30,20 +30,20 @@ def empty(cls, shape):
3030
ctypes.c_uint(nrows),
3131
ctypes.c_uint(ncols))
3232

33-
dll.check(status)
33+
bridge.check(status)
3434

3535
return Matrix(hnd)
3636

3737
def __del__(self):
38-
dll.check(wrapper.loaded_dll.CuBool_Matrix_Free(wrapper.instance, self.hnd))
38+
bridge.check(wrapper.loaded_dll.CuBool_Matrix_Free(wrapper.instance, self.hnd))
3939

4040
def resize(self, nrows, ncols):
4141
status = wrapper.loaded_dll.matrix_resizer(wrapper.instance,
4242
self.hnd,
4343
ctypes.c_uint(nrows),
4444
ctypes.c_uint(ncols))
4545

46-
dll.check(status)
46+
bridge.check(status)
4747

4848
def build(self, rows, cols, nvals):
4949
if len(rows) != len(cols) or len(rows) != nvals:
@@ -58,7 +58,7 @@ def build(self, rows, cols, nvals):
5858
t_cols,
5959
ctypes.c_size_t(nvals))
6060

61-
dll.check(status)
61+
bridge.check(status)
6262

6363
def duplicate(self):
6464
hnd = ctypes.c_void_p(0)
@@ -67,7 +67,7 @@ def duplicate(self):
6767
self.hnd,
6868
ctypes.byref(hnd))
6969

70-
dll.check(status)
70+
bridge.check(status)
7171

7272
return Matrix(hnd)
7373

@@ -79,7 +79,7 @@ def nrows(self) -> int:
7979
self.hnd,
8080
ctypes.byref(result))
8181

82-
dll.check(status)
82+
bridge.check(status)
8383
return int(result.value)
8484

8585
@property
@@ -90,7 +90,7 @@ def ncols(self) -> int:
9090
self.hnd,
9191
ctypes.byref(result))
9292

93-
dll.check(status)
93+
bridge.check(status)
9494
return int(result.value)
9595

9696
@property
@@ -101,7 +101,7 @@ def nvals(self) -> int:
101101
self.hnd,
102102
ctypes.byref(result))
103103

104-
dll.check(status)
104+
bridge.check(status)
105105
return int(result.value)
106106

107107
@property
@@ -121,6 +121,6 @@ def to_lists(self):
121121
cols,
122122
ctypes.byref(nvals))
123123

124-
dll.check(status)
124+
bridge.check(status)
125125

126126
return rows, cols

python/pycubool/mxm.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from . import wrapper
2-
from . import dll
2+
from . import bridge
33
from . import matrix
44

55
__all__ = [
@@ -13,4 +13,4 @@ def mxm(result_matrix: matrix.Matrix, a_matrix: matrix.Matrix, b_matrix: matrix.
1313
a_matrix.hnd,
1414
b_matrix.hnd)
1515

16-
dll.check(status)
16+
bridge.check(status)

python/pycubool/wrapper.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import os
22
import ctypes
3-
from . import dll
3+
from . import bridge
44

55
__all__ = [
66
"singleton",
@@ -48,7 +48,7 @@ def __init__(self):
4848
self.loaded_dll = None
4949

5050
self.load_path = os.environ["CUBOOL_PATH"]
51-
self.loaded_dll = dll.load_and_configure(self.load_path)
51+
self.loaded_dll = bridge.load_and_configure(self.load_path)
5252

5353
self._setup_instance()
5454

@@ -58,14 +58,14 @@ def __del__(self):
5858

5959
def _setup_instance(self):
6060
self.instance = ctypes.c_void_p(None)
61-
self._descInstance = dll.configure_instance_desc()
61+
self._descInstance = bridge.configure_instance_desc()
6262
self._descInstance.memoryType = 0
6363

6464
status = self.loaded_dll.CuBool_Instance_NewExt(ctypes.byref(self._descInstance),
6565
ctypes.byref(self.instance))
6666

67-
dll.check(status)
67+
bridge.check(status)
6868

6969
def _release_instance(self):
7070
status = self.loaded_dll.CuBool_Instance_Free(self.instance)
71-
dll.check(status)
71+
bridge.check(status)

python/tests/test_example.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,10 @@ def transitive_closure(a: pycubool.Matrix):
1111
"""
1212

1313
t = a.duplicate() # Duplicate matrix where to store result
14+
total = 0 # Current number of values
1415

15-
total = t.nvals # Current number of values
16-
changing = True # track changing
17-
18-
while changing:
19-
pycubool.mxm(t, t, t) # t += t * t
20-
changing = t.nvals != total
16+
while total != t.nvals:
2117
total = t.nvals
18+
pycubool.mxm(t, t, t) # t += t * t
2219

2320
return t

tests/test_library_api.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ TEST(CuBoolInstance, SetupExt) {
8989

9090
/**
9191
* Performs transitive closure for directed graph
92+
*
9293
* @param Inst Library instance, which provides context for operations
9394
* @param A Adjacency matrix of the graph
9495
* @param T Reference to the handle where to allocate and store result
@@ -98,17 +99,15 @@ TEST(CuBoolInstance, SetupExt) {
9899
CuBoolStatus TransitiveClosure(CuBoolInstance Inst, CuBoolMatrix A, CuBoolMatrix* T) {
99100
CuBool_Matrix_Duplicate(Inst, A, T); /** Create result matrix and copy initial values */
100101

101-
CuBoolSize_t total;
102-
CuBool_Matrix_Nvals(Inst, *T, &total); /** Query current number on non-zero elements */
103-
104-
CuBoolSize_t current = total; /** Loop while values are added */
102+
CuBoolSize_t total = 0;
103+
CuBoolSize_t current;
104+
CuBool_Matrix_Nvals(Inst, *T, &current); /** Query current number on non-zero elements */
105105

106-
do {
106+
while (current != total) { /** Loop while values are added */
107107
total = current;
108108
CuBool_MxM(Inst, *T, *T, *T); /** T += T * T */
109109
CuBool_Matrix_Nvals(Inst, *T, &current);
110110
}
111-
while (current != total);
112111

113112
return CUBOOL_STATUS_SUCCESS;
114113
}

0 commit comments

Comments
 (0)