Skip to content
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

[ENH, WIP] Adding CMI test #12

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

[ENH, WIP] Adding CMI test #12

wants to merge 1 commit into from

Conversation

adam2392
Copy link
Collaborator

@adam2392 adam2392 commented Apr 21, 2023

Towards: #5

Changes proposed in this pull request:

  • CMI based CI test

This is still a draft.

Before submitting

  • I've read and followed all steps in the Making a pull request
    section of the CONTRIBUTING docs.
  • I've updated or added any relevant docstrings following the syntax described in the
    Writing docstrings section of the CONTRIBUTING docs.
  • If this PR fixes a bug, I've added a test that will fail without my fix.
  • If this PR adds a new feature, I've added tests that sufficiently cover my new functionality.
  • I have added a changelog entry succintly describing the change in this PR in the whats_new relevant version document.

After submitting

  • All GitHub Actions jobs for my pull request have passed.

Signed-off-by: Adam Li <[email protected]>
@codecov-commenter
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (main@138539c). Click here to learn what that means.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #12   +/-   ##
=======================================
  Coverage        ?   22.08%           
=======================================
  Files           ?        6           
  Lines           ?      240           
  Branches        ?       31           
=======================================
  Hits            ?       53           
  Misses          ?      186           
  Partials        ?        1           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

n_shuffle: int = 100,
random_seed: Optional[int] = None
) -> PValueResult:
rng = np.random.default_rng(random_seed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning this?

n_shuffle: int = 100,
random_seed: Optional[int] = None
) -> PValueResult:
rng = np.random.default_rng(random_seed)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returning?

val = hxyz - (hxz + hyz - hz).mean()
return val

def _preprocess_data(self, data: pd.DataFrame) -> pd.DataFrame:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_, indices = nbrs.kneighbors(z_arr)
elif method == "kdtree":
tree_xyz = scipy.spatial.cKDTree(z_arr)
indices = tree_xyz.query(z_arr, k=k, p=np.inf, eps=0.0, workers=n_jobs)[1].astype(np.int32)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else: return ValueError

rng = np.random.default_rng(seed=random_seed)

# initialize the final permutation order
restricted_perm = np.zeros((n_samples,))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
restricted_perm = np.zeros((n_samples,))
restricted_perm = np.zeros((n_samples,), dtype=np.int32)

if it has not been used to permute another sample. If it has been, then the
algorithm looks at the next nearest-neighbor and so on. If all k-nearest
neighbors of a sample has been checked, then a random neighbor is chosen. In this
manner, the algorithm tries to perform permutation without replacement, but
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

citation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants