Skip to content

Commit f954e89

Browse files
authored
Merge pull request #179 from kant2002/kant/update-packaging
Test on experimental branch
2 parents 0d2fc2d + 67032dd commit f954e89

12 files changed

Lines changed: 471 additions & 12 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Random editor stuff
22
*~
3+
*.swp
34

45
# Python byte-compiled / optimized / DLL files
56
*.pyc
@@ -9,11 +10,14 @@ src/Python/dist/*
910
src/Python/tests/test_chunk*
1011
src/Python/wcon.egg*
1112
.pypirc
13+
openworm/
1214

1315
#Matlab
1416
*.asv
1517

1618
# Scala
1719
src/scala/target/*
20+
src/scala/**/target/*
21+
1822
/src/Python/example_saved_file.WCON
1923
/src/Python/wcon/wcon_schema.json

src/Python/Pipfile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
pandas = "*"
8+
six = "*"
9+
numpy = "*"
10+
psutil = "*"
11+
jsonschema = "*"
12+
scipy = "*"
13+
14+
[dev-packages]
15+
16+
[requires]
17+
python_version = "3.9"

src/Python/Pipfile.lock

Lines changed: 395 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Python/pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[project]
2+
name = "wcon"
3+
version = "1.1.0"
4+
authors = [
5+
{ name="Kerr, R; Brown, A; Currie, M; OpenWorm", email="ichoran@gmail.com" },
6+
]
7+
description = "Worm tracker Commons Object Notation"
8+
readme = "README.md"
9+
requires-python = ">=3.9"
10+
classifiers = [
11+
'Development Status :: 4 - Beta',
12+
'Intended Audience :: Science/Research',
13+
'Topic :: Scientific/Engineering :: Bio-Informatics',
14+
"Programming Language :: Python :: 3",
15+
"Operating System :: OS Independent",
16+
]
17+
license = "MIT"
18+
19+
[project.urls]
20+
Homepage = "https://github.com/openworm/tracker-commons"
21+
Issues = "https://github.com/openworm/tracker-commons/issues"

src/Python/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
six
2+
jsonschema
3+
numpy
4+
pandas
5+
psutil
6+
scipy

src/Python/tests/.bbb.wcon.swp

-16 KB
Binary file not shown.

src/Python/tests/diagnostic_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import time
2121
import pprint as pp
2222

23-
sys.path.append('..')
23+
dir_path = os.path.dirname(os.path.realpath(__file__))
24+
sys.path.append(os.path.join(dir_path, '..'))
2425
from wcon import WCONWorms, MeasurementUnit
2526
from wcon.measurement_unit import MeasurementUnitAtom
2627

src/Python/tests/tests.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@
1616
import shutil
1717
from scipy.constants import pi
1818

19-
sys.path.append('..')
19+
dir_path = os.path.dirname(os.path.realpath(__file__))
20+
sys.path.append(os.path.join(dir_path, '..'))
2021
from wcon import WCONWorms, MeasurementUnit
2122
from wcon.measurement_unit import MeasurementUnitAtom
2223

23-
2424
def setUpModule():
2525
# If the wcon module is installed via pip, wcon_schema.json is included
2626
# in the proper place. In the git repo it is not, however, so to test
27-
# we must copy it over temporarily, then remove it once tests are done.
28-
shutil.copyfile('../../../wcon_schema.json', '../wcon/wcon_schema.json')
27+
# we must copy it over temporarily, then remove it once tests are done.
28+
shutil.copyfile(os.path.join(dir_path, '..', '..', '..', 'wcon_schema.json'), os.path.join(dir_path, '..', 'wcon', 'wcon_schema.json'))
2929

3030

3131
def tearDownModule():
32-
os.remove('../wcon/wcon_schema.json')
32+
os.remove(os.path.join(dir_path, '..', 'wcon', 'wcon_schema.json'))
3333

3434

3535
def flatten(list_of_lists):
@@ -192,7 +192,9 @@ def _validate_from_schema(self, wcon_string):
192192
except AttributeError:
193193
# Only load _wcon_schema if this method gets called. Once
194194
# it's loaded, though, persist it in memory and don't lose it
195-
with open("../../../wcon_schema.json", "r") as wcon_schema_file:
195+
wcon_schema_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
196+
'..', '..', '..', 'wcon_schema.json'))
197+
with open(wcon_schema_path, "r") as wcon_schema_file:
196198
self._wcon_schema = json.loads(wcon_schema_file.read())
197199

198200
# Now that the schema has been loaded, we can try again
@@ -204,7 +206,8 @@ def test_schema(self):
204206
self._validate_from_schema(basic_wcon)
205207

206208
def test_equality_operator(self):
207-
JSON_path = '../../../tests/minimax.wcon'
209+
JSON_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
210+
'..', '..', '..', 'tests', 'minimax.wcon'))
208211
w2 = WCONWorms.load_from_file(JSON_path)
209212
w2.units['y'] = MeasurementUnit.create('m')
210213
w2data = w2.data.copy()

src/Python/wcon/measurement_unit.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
import operator as op
2424
from scipy.constants import convert_temperature, pi
2525

26+
def F2C(val):
27+
return convert_temperature(val, 'F', 'C')
28+
def C2F(val):
29+
return convert_temperature(val, 'C', 'F')
30+
def K2C(val):
31+
return convert_temperature(val, 'K', 'C')
32+
def C2K(val):
33+
return convert_temperature(val, 'C', 'K')
2634

2735
def C2C(x):
2836
"""

src/Python/wcon/wcon_data.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ def df_upsert(src, dest):
116116
src.columns.isin(dest.columns)]
117117

118118
# Sort our slices so they will be lined up for comparison
119-
dest_sliced.sort_index(inplace=True)
120-
src_sliced.sort_index(inplace=True)
119+
dest_sliced.sort_index(axis=1, inplace=True)
120+
src_sliced.sort_index(axis=1, inplace=True)
121121

122122
# Align src_sliced's row/column labels to dest_sliced. The two
123123
# were built with independent .isin() masks so column order may
@@ -231,7 +231,10 @@ def convert_origin(df):
231231

232232
# Now reset our 'ox' values to zero.
233233
if offset in cur_worm.columns.get_level_values(0):
234-
df.loc[:, (worm_id, offset)] = np.zeros(ox_column.shape)
234+
df.loc[:, (worm_id, offset)] = np.zeros(ox_column.shape, dtype=pd.Int64Dtype)
235+
else:
236+
all_x_columns = cur_worm.loc[:, (coord)].fillna(0).astype('float64')
237+
df.loc[:, (worm_id, coord)] = all_x_columns.values
235238

236239
# Drop the offset columns entirely from the dataframe.
237240
# This is so DataFrames with and without offsets

0 commit comments

Comments
 (0)