Quantco / tabmat

Efficient matrix representations for working with tabular data

Home Page:https://tabmat.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use `slice(None)` instead of `None` for non-existant row and col filters.

tbenthompson opened this issue · comments

As an alternative to the if clause, you could replace None with slice(None). You could then use it for indexing and it wouldn't return a copy. I don't know where else in the code base you use setup_restrictions, but it could generalize.

Originally posted by @lbittarello in #89 (comment)

My comment from the PR:
I like the idea. But, I'd also like to leave this as is for now. I worry that it'll be a big quagmire of having to change essentially every method down the tree because rows and cols get passed to self.mat.sandwich and self.mat.transpose_matvec. I'll split this out into an issue. Feel free to close it if you don't think it's worth having an issue.

Another question here: is there an easy way to handle slice(None) in Cython code?

I don't know any Cython. :T @xhochy?

I have no idea about this but this is probably somewhere in the pandas code. There you often have slice(None) and a lot of Cython.

Apologies! I didn't mean to make this into a public discussion eating up people's time -- just sort of some notes to myself since I think I'm the mostly likely person to make these changes. I'll make that more clear next time.

Thanks for the suggestion on looking at pandas.