Skip to content

Commit 614457f

Browse files
authored
Fixes URL regex, updates nosetests set up, bumps up the version for release. (#9)
1 parent 1e1679d commit 614457f

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

docs/source/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
author = 'Eugene Morozov'
2525

2626
# The short X.Y version
27-
version = 'v1.1.0'
27+
version = 'v1.1.1'
2828
# The full version, including alpha/beta/rc tags
29-
release = 'v1.1.0'
29+
release = 'v1.1.1'
3030

3131

3232
# -- General configuration ---------------------------------------------------

rdfpandas/graph.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ def to_graph(df: pd.DataFrame, namespace_manager: NamespaceManager = None) -> Gr
3939

4040
for (index, series) in df.iterrows():
4141
for (column, value) in series.iteritems():
42-
match = re.search('([\w?:/.]*)(\{(\w*)\})?(\[(\d*)\])?(\(([\w?:/.]*)\))?(@(\w*))?', column)
43-
42+
# Matching unreserved, gen-delims and sub-delims with exception of "(", ")", "@", "[" and "]" from RFC 3986
43+
match = re.search('([\w\-._~:/?#!$&\'*+,;=]*)(\{(\w*)\})?(\[(\d*)\])?(\(([\w?:/.]*)\))?(@(\w*))?', column)
4444
if pd.notna(value) and pd.notnull(value):
4545
s = _get_identifier(prefixes, index)
4646
p = _get_identifier(prefixes, match.group(1))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
setup(
1313
name = 'rdfpandas',
14-
version = '1.1.0',
14+
version = '1.1.1',
1515
description = 'RDF support for Pandas',
1616
long_description = readme,
1717
author = 'Eugene Morozov',

tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .test_graph import ConversionTestCase

tests/test_graph.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,12 @@ def test_should_convert_data_frame_to_graph_uriref(self):
177177

178178
ds1 = pd.Series(data=['https://google.com'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)
179179
ds2 = pd.Series(data=['skos:broader'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)
180+
ds3 = pd.Series(data=['skos:Concept'], index = ['http://github.com/cadmiumkitty/rdfpandas/one'], dtype = np.unicode_)
180181

181182
df = pd.DataFrame({
182183
'http://github.com/cadmiumkitty/rdfpandas/uri{URIRef}': ds1,
183-
'http://github.com/cadmiumkitty/rdfpandas/curie{URIRef}': ds2
184+
'http://github.com/cadmiumkitty/rdfpandas/curie{URIRef}': ds2,
185+
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type{URIRef}': ds3
184186
})
185187

186188
g_expected = Graph()
@@ -191,6 +193,9 @@ def test_should_convert_data_frame_to_graph_uriref(self):
191193
g_expected.add((URIRef('http://github.com/cadmiumkitty/rdfpandas/one'),
192194
URIRef('http://github.com/cadmiumkitty/rdfpandas/curie'),
193195
URIRef('skos:broader')))
196+
g_expected.add((URIRef('http://github.com/cadmiumkitty/rdfpandas/one'),
197+
URIRef('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
198+
URIRef('skos:Concept')))
194199

195200
g_result = rdfpandas.to_graph(df)
196201

@@ -333,7 +338,7 @@ def test_should_roundtrip_csv_to_graph_to_csv(self):
333338
"""Should roundtrip DF -> Graph -> DF
334339
"""
335340

336-
df = pd.read_csv('./csv/test.csv', index_col = '@id', keep_default_na = True)
341+
df = pd.read_csv('./tests/csv/test.csv', index_col = '@id', keep_default_na = True)
337342
namespace_manager = NamespaceManager(Graph())
338343
namespace_manager.bind('skos', SKOS)
339344
namespace_manager.bind('rdfpandas', Namespace('http://github.com/cadmiumkitty/rdfpandas/'))
@@ -348,7 +353,7 @@ def test_should_roundtrip_graph_to_csv_to_graph(self):
348353
"""
349354

350355
g = rdflib.Graph()
351-
g.parse('./rdf/test.ttl', format = 'ttl')
356+
g.parse('./tests/rdf/test.ttl', format = 'ttl')
352357
df = rdfpandas.to_dataframe(g)
353358
print(df.T)
354359
g_result = rdfpandas.to_graph(df, g.namespace_manager)

0 commit comments

Comments
 (0)